Database Reference
In-Depth Information
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
The \G at the end of the command in this example is an alternative
to using a semicolon ( ; ) and when used it presents the output in a
slightly different way which works well for this example.
The actual CREATE TABLE command that is displayed is slightly different from the
CREATE TABLE command that we used to create it, but the table created is exactly
the same. The differences exist because MariaDB is giving us enough information to
recreate the table exactly, even if we're creating it on a different server with different
defaults.
For example, the ENGINE and DEFAULT CHARSET parts after the column definitions
are default table options on this MariaDB Server. Here they are specified because on
a different MariaDB server the defaults may be different.
Full documentation of the SHOW CREATE TABLE command can be found at
https://mariadb.com/kb/en/show-create-table/ .
Exploring the structure of a table
If we don't necessarily want to look at the commands used to create a table but we
want to know the structure of a table, we can use the DESCRIBE command as follows:
MariaDB [test]> DESCRIBE employees;
+-----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| surname | varchar(100) | YES | | NULL | |
| givenname | varchar(100) | YES | | NULL | |
| pref_name | varchar(50) | YES | | NULL | |
| birthday | date | YES | | NULL | |
+-----------+--------------+------+-----+---------+----------------+
5 rows in set (0.03 sec)
Full documentation of the DESCRIBE command can be found at https://mariadb.
com/kb/en/describe/ .
 
Search WWH ::




Custom Search