mysql (一.建表)
原创
©著作权归作者所有:来自51CTO博客作者wx360w684er9d的原创作品,请联系作者获取转载授权,否则将追究法律责任
CREATE TABLE t_book_type(
id INT PRIMARY KEY AUTO_INCREMENT,
bookTypeName VARCHAR(20),
bookTypeDesc VARCHAR(200)
);
CREATE TABLE t_book(
id INT PRIMARY KEY AUTO_INCREMENT,
bookName VARCHAR(20),
author VARCHAR(10),
price DECIMAL(6,2),
bookTypeId INT ,
CONSTRAINT `fk` FOREIGN KEY(`bookTypeId`) REFERENCES `t_book_type`(`id`)
);
desc t_bookType;
show create table t_bookType;
alter table t_book rename t_book2;
alter table t_book change bookName bookName2 varchar(20);
alter table t_book add testField int first ;
alter table t_book drop testField;
drop table t_bookType;
drop table t_book;