mysql sql开发
创建表
创建表语法:
-- 基本语法
CREATE TABLE 表名称(
字段名1 数据类型1,
字段名2 数据类型2,
字段名3 数据类型3);
例子:
创建一个actor表,包含如下列信息
列表 |
类型 |
actor_id |
smallint(5) |
first_name |
varchar(45) |
last_name |
varchar(45) |
last_update |
date |
mysql> create table actor (actor_id smallint(5),
-> first_name varchar(45),
-> last_name varchar(45),
-> last_update date
-> );
Query OK, 0 rows affected (2.20 sec)
mysql> desc actor;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| actor_id | smallint(5) | YES | | NULL | |
| first_name | varchar(45) | YES | | NULL | |
| last_name | varchar(45) | YES | | NULL | |
| last_update | date | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+
4 rows in set (0.39 sec)