mysql> CREATE TABLE pet ( petid int unsigned not null auto_increment, name VARCHAR(20) not null, owner VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE not null, death DATE, primary key (petid) );Once you have your tables created you can see the whole list using show tables command
mysql> show tables; Tables_in_danil pet testand also retrieve information about any table usind describe command
mysql> describe pet;
| Field | Type | Null | Key | Default | Extra |
|---|---|---|---|---|---|
| petid | int(10) unsigned | PRI | auto_increment | ||
| name | varchar(20) | ||||
| owner | varchar(20) | YES | |||
| species | varchar(20) | YES | |||
| sex | char(1) | YES | |||
| birth | date | 0000-00-00 | |||
| death | date | YES |
mysql> SHOW CREATE TABLE pet;You can find more information abou show command here.
| Type | Range | Storage(bytes) | Description |
|---|---|---|---|
| tinyint[(M)] | -127..128 or 0..255 | 1 | Very small integers |
| smallint[(M)] | -32768..32767 or 0..65535 | 2 | Small integers |
| mediumint[(M)] | -8388608..8388607 or 0..16777215 | 3 | Medium integers |
| int[(M)] | -231..231-1 or 0..231-1 | 4 | Regular integers |
| integer[(M)] | -231..231-1 or 0..231-1 | 4 | Synonym for int |
| bigint[(M)] | -263..263-1 or 0..263-1 | 8 | Big integers |
| Type | Range | Storage(bytes) | Description |
|---|---|---|---|
| float(precision) | depends on precision | varies | Can be used to specify single or duble floating point numbers |
| float[(M,D)] | ±1.175494351E-38 ±3.402823466E+38 |
4 | Single precision floating point numbers |
| double[(M,D)] | ±1.7976931348623157E+308 ±2.225073858507201E-308 |
8 | Double precision floating point numbers |
| double precision[(M,D)] | ±1.7976931348623157E+308 ±2.225073858507201E-308 |
8 | Synonym for double |
| real[(M,D)] | ±1.7976931348623157E+308 ±2.225073858507201E-308 |
8 | Synonym for double |
| decimal[(M[,D])] | varies | M+2 | Floating point number stored as char. The range depends on M, the display width. |
| numeric[(M[,D])] | varies | M+2 | Synonym for decimal |
| Type | Range | Description |
|---|---|---|
| date | 1000-01-01 ... 9999-12-31 | A date. Will be displayed as YYYY-MM-DD |
| time | -838:59:59 ... 838:59:59 | A time. Will be displayed as HH:MM:SS. Note that the range is much wider than you will probably ever want to use. |
| datetime | 1000-01-01 00:00:00 ... 9999-12-31 23:59:59 | A date and time. Will be displayed as YYYY-MM-DD HH:MM:SS. |
| timestamp[(M)] | 1970-01-01 00:00:00 ... sometime in 2073 | A timestamp, useful for transaction reporting. The display format depends on M. |
| year[(2|4)] | 70..69 (1970..2069) 1901..2155 |
A year. You can specify two or four digit format. |
| Type Specified | Display |
|---|---|
| timestamp | YYYYMMDDHHMMSS |
| timestamp(14) | YYYYMMDDHHMMSS |
| timestamp(12) | YYYYMMDDHHMM |
| timestamp(10) | YYYYMMDDHH |
| timestamp(8) | YYYYMMDD |
| timestamp(6) | YYYYMM |
| timestamp(4) | YYYY |
| timestamp(2) | YY |
| Type | Range | Description |
|---|---|---|
| [national] char(M) [binary] | 1 to 255 characters | Fixed length string of length M, where M is between 1 and 255. The national keyword specifies that the default set character should be used (part of ANSI stabdared). The binary keyword specifies that the data should be treated as case sensitive. (The default is case insensitive.) |
| [national] varchar(M) [binary] | 1 to 255 characters | Same as above, except they are variable length. |
| Type | Max Length | Description |
|---|---|---|
| tinyblob | 28-1 | A tiny binary large object field. |
| tinytext | 28-1 | A tiny tetx field. |
| blob | 216-1 | A normal size binary large object field. |
| text | 216-1 | A normal size text field. |
| mediumblob | 224-1 | A medium-sized binary large object field. |
| mediumtext | 224-1 | A medium-sized text field. |
| longblob | 232-1 | A long binary large object field. |
| longtext | 232-1 | A long text field. |
In practice, TEXT and BLOB objects are the same except that TEXT is case insensitive and BLOB is case sensitive.
ENUM is enumeration. It is very similar to SET, except that column of this type can have only one of the specified values or NULL, and you can have up to 65535 things in the enumeration.
You can find more iformation about all of these types in MySQL standard documentation.