> For the complete documentation index, see [llms.txt](https://bloxsql.metatable.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bloxsql.metatable.dev/101/create-table.md).

# Create Table

## Create MySQL Table

In this little course today we will be creating a table with the name "players", with 2 columns called "username", and "userid".\
\
Example:

```sql
CREATE TABLE players (
userid INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(30) NOT NULL
)
```

Notes (source: <https://www.w3schools.com/php/php_mysql_create_table.asp>)<br>

The data type specifies what type of data the column can hold. For a complete reference of all the available data types, go to our [Data Types reference](https://www.w3schools.com/sql/sql_datatypes.asp).

After the data type, you can specify other optional attributes for each column:

* NOT NULL - Each row must contain a value for that column, null values are not allowed
* DEFAULT value - Set a default value that is added when no other value is passed
* UNSIGNED - Used for number types, limits the stored data to positive numbers and zero
* AUTO INCREMENT - MySQL automatically increases the value of the field by 1 each time a new record is added
* PRIMARY KEY - Used to uniquely identify the rows in a table. The column with the PRIMARY KEY setting is often an ID number and is often used with AUTO\_INCREMENT<br>

## BLOXsql Example

```lua
local BLOXsql = require(16229654720) 
local Settings= {
	-- Ensure you whitelist "141.98.74.17" with your database host.
	Username = "rampage_admin",
	Password = "1234567890",
	Host = "localhost",
	Database = "rampage_main"
}


BLOXsql:execute("CREATE TABLE players (userid INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,username VARCHAR(30) NOT NULL)", Settings)
```
