# Creating Schema (Database)

__*lower_case_table_names*__

+ Syntax:
  + `CREATE DATABASE [IF NOT EXISTS] {database_name} [{options}]` 
  + `CREATE SCHEMA [IF NOT EXISTS] {schema_name} [{options}]` 
+ Objects in the database can only be named using English letters, numbers, and underscores
  + The name cannot exceed 64 characters
  + Following characters cannot be used `ASCII(0)`, `ASCII(255)`, `/`, `\`, and `.`   
  + You can use reserved words and special characters, but only if you enclose them in backquotes
+ TiDB stores object names in a case-sensitive manner, but compares them in a case-insensitive manner
+ Dropping a database: `DROP DATABASE [IF EXISTS] {database_name}`
  + Be careful that this is an action that cannot be undone

```
tidb> SHOW VARIABLES LIKE 'lower_case_%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| lower_case_file_system | 1     |
| ~!@lower_case_table_names@!~ | 2     |
+------------------------+-------+
```

----------------------------------------------------------------------------------------------------------
Currently, TiDB only supports setting the lower-case-table-names value to 2, that is, table names are saved case sensitively and compared in lowercase.

`CREATE DATABASE` is used to create a database, and you can specify the default properties of the database, such as the database default character set and collation.

```
CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
    [create_specification] ...
```

```
create_specification:
    [DEFAULT] CHARACTER SET [=] charset_name
  | [DEFAULT] COLLATE [=] collation_name
```

An error is reported when creating a database that already exists and `IF NOT EXISTS` is not specified.

The `create_specification` option specifies database-specific `CHARACTER SET` and `COLLATE`. Character sets and collation will be explained in the next section.

Dropping objects in TiDB can sometimes be undone depending on the GC settings etc. We will talk about table flashback features later.
