# Creating, modifying, removing database objects

### Tables

#### Create table

```sql
CREATE TABLE <table-name>
    (<column name> <data type>[(<size>)],
    <column name> <data type>[(<size>)],...);
```

#### Alter table

```sql
ALTER TABLE <table name> ADD <column name>
    <data type> <size>;
```

#### Drop table

```sql
DROP TABLE <table name>;
```

### Indexes

#### Create index

```sql
CREATE [UNIQUE] [CLUSTERED | NONCLUSTERED] INDEX <index_name>
ON <table_name> | <view_name> ( column [ ASC | DESC ],...)
[ON filegroup]
```

#### **Rename index**

```sql
ALTER INDEX <index_name>
{[RENAME TO <new_name>] |
 [REBUILD TABLESPACE <tablespace_name>]
};
```

#### Drop index

```sql
DROP INDEX <table_name>.<index_name> [,...]
```

### Views

#### Create view

```sql
CREATE VIEW [[<database_name>.]<owner>.]<view_name>
     [(<column_name>,...)] [WITH {ENCRYPTION | SCHEMABINDING |
     VIEW_METADATA,...}] AS select_statement [WITH CHECK OPTION]
```

#### Alter view

```sql
ALTER VIEW [<qualifier>.]<view_name>
    [(<column_name>,...)] [WITH {ENCRYPTION | SCHEMABINDING |
    VIEW_METADATA}] AS <select_statement> [WITH CHECK OPTION]
```

#### Drop view

```sql
DROP VIEW <view_name> [,...]
```

### Schemas

#### Create schema

```sql
CREATE SCHEMA AUTHORIZATION
    <owner> <create_object_statement>,...
    <grant_privilege_statement>,...
```

#### Drop schema

```sql
DROP SCHEMA <schema_name> RESTRICT
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dotnetweb30-ke.gitbook.io/ke/construction-db/sql/creating-modifying-removing-database-objects.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
