Mysql创建和操纵表的命令

mysql> create database name;
mysql> drop databasename;
mysql> create table customers( #创建表
cust_id int   not null auto_increment, #自动递增
cust_name char(50)  not null
,
cust_address char(50) null,
cust_city char(50) null,
cust_state char(5) null,
cust_zip char(10) null,
cust_country char(50) null,
cust_contact char(50) null,
cust_email char(255) null,
primary key (cust_id))engine= InnoDB; #事务处理引擎
mysql> drop table customers

#删除表
mysql> alter table vendors
add vend_phone char(20); #增加一列
mysql> alter table vendors
drop column vend_phone ;   #删除一列
mysql> alter table products add primary key (prod_id);  #指定主键值
mysql> alter table products drop primary key;  #删除主键值

mysql> alter table products auto_increment=10001;  #设定主键值的初始值

mysql> alter table products alter column vend_id set default '10';  #设定指定列的初始值

mysql> alter table products modify column vend_id int not null; #更改列的属性值
mysql> alter table products modify column prod_id int not null auto_increment; #主键值自动递增
mysql> alter table products engine='MyISAM/InnoDB/MEMORY'; #更事务引擎


你可能感兴趣的:(primary,create,customers)