9、修改表结构,增加一列
alter table book add column weight float(4,2) default 1.00;
修改表结构,删除一列
alter table book drop column weight;
复制一张表 (含约数,不含数据)
create table book2 like book1;
复制一张表 (不含约数,含数据)
create table book3 as (select * from book1);
create table book(
tushubianhao char(20) NOT NULL PRIMARY KEY,
tushuleibie varchar(20)NOT NULL DEFAULT'计算机',
shuming varchar(40)NOT NULL,
zuozhe char(10)NOT NULL,
chubanshe varchar(20)NOT NULL,
chubanshijian date NOT NULL,
danjia float(5) NOT NULL,
shuliang int(5),
zhekou float(3),
fengmiantupian blob)ENGINE=InnoDB;
desc book;
+----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| tushubianhao | char(20) | NO | PRI | NULL | |
| tushuleibie | varchar(20) | NO | | 计算机 | |
| shuming | varchar(40) | NO | | NULL | |
| zuozhe | char(10) | NO | | NULL | |
| chubanshe | varchar(20) | NO | | NULL | |
| chubanshijian | date | NO | | NULL | |
| danjia | float | NO | | NULL | |
| shuliang | int(5) | YES | | NULL | |
| zhekou | float | YES | | NULL | |
| fengmiantupian | blob | YES | | NULL | |
+----------------+-------------+------+-----+---------+-------+
10 rows in set (0.02 sec
网友评论