CREATE DATABASE IF NOT EXISTS books;
ALTER DATABASE books CHARACTER SET utf8;
ALTER TABLE book CHARACTER SET utf8;
ALTER TABLE author CHARACTER SET utf8;
DESC book;
drop database if EXISTS books;
DROP TABLE book;
CREATE TABLE book(
id INT,
bName VARCHAR(20),
price DOUBLE,
authorId INT,
publishDate datetime
);
CREATE TABLE author(
id INT,
au_name VARCHAR(20),
nation VARCHAR(10)
);
ALTER TABLE book CHANGE COLUMN publishDate pubDate DATETIME;
DESC book;
ALTER TABLE book MODIFY COLUMN pubDate TIMESTAMP;
SELECT *FROM book;
ALTER TABLE author ADD COLUMN annual DOUBLE;
DESC author;
ALTER TABLE author DROP COLUMN annual;
ALTER TABLE author RENAME TO b_author;
DROP TABLE IF EXISTS b_author;
show TABLES;
DROP DATABASE IF EXISTS 旧库名;
CREATE DATABASE 新库名;
DROP TABLE IF EXISTS 旧表名;
CREATE TABLE 新表名;
SELECT DATABASE();
INSERT INTO books.author(id,au_name,nation) VALUES
(2,'鲁迅','中国'),
(3,'唐家三少','中国'),
(4,'天蚕土豆','中国');
CREATE TABLE copy LIKE author;
SELECT *FROM author;
SELECT *FROM copy2;
DESC copy;
CREATE TABLE copy2
SELECT *FROM author;
DROP TABLE cpoy2;
CREATE TABLE copy3
SELECT id,au_name FROM author
WHERE 0;
DESC copy3;