Database tables can be created explicitly or in other ways, such as from an existing table. When creating tables, options can be specified for the tables contents, as well.
This example uses the MySQL relational database. A database on the database server must already exist.
Once the connection the database server has been established, you will need to create a table within a database. This could have several behaviors. If there is no default database, you could declare the default database with:
Otherwise, you can specify the database’s name within the table declaration. The database on the database server must already exist, many can exist for any one database server.
To create a table, simply enter:
create table TABLE_NAME (COLUMN_NAME int, COLUMN_TWO_NAME varchar(30));
when a default database has been selected. This will create a table, arbitrarily with two columns of two different data types.
To specify the database in the creation statement:
create table DATABASE_NAME.TABLE_NAME (COLUMN_NAME int, COLUMN_TWO_NAME varchar(30));
Indexes can also be specified in the table creation statement.
To view the definition of the table, you could either use:
show create table TABLE_NAME