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`)
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;