DROP DATABASE IF EXISTS databaseweb; --delete the mode if it exists databaseweb
Create DATABASE databaseweb CHARACTER SET utf8;--creation mode Databaseweb. Using UTF8 encoding
Use databaseweb;--switch to mode Databaseweb, the following operations are under Databaseweb
Set NAMES ' UTF8 ';---the console uses UTF8 encoding, and if GBK encoding is used, the insertion of Chinese character times is wrong
drop table if EXISTS tb_person;--, if present, deletes tables Tb_person
CREATE TABLE Tb_person (--Creating tables
ID INTEGER auto_increment COMMENT ' id ',
Name VARCHAR (COMMENT ' name '),
English_name VARCHAR COMMENT ' English name ',
Age INTEGER UNSIGNED COMMENT ' ages ',
Sex VARCHAR (+) COMMENT ' sex ',
Birthday Date COMMENT ' birthdate ',
Description TEXT COMMENT ' remarks ',
Create_time TIMESTAMP DEFAULT current_timestamp () COMMENT ' creation time ',
PRIMARY KEY (ID)
);
INSERT into Tb_person--inserting data
(Name, English_name, age, sex, birthday, description) values
(' Zhujia ', ' Helloweenvsfei ', ' + ', ' man ', ' 1989-08-09 ', ' noinfo ');
INSERT into Tb_person
(Name, English_name, age, sex, birthday, description) values
(' Cobain ', ' Kurt Cobain ', ' 27 ', ' Male ', ' 1967-02-20 ', ' Nirvana ');
INSERT into Tb_person
(Name, English_name, age, sex, birthday, description) values
(' Faye Wong ', ' Faye ', ' 31 ', ' female ', ' 1969-08-08 ', ' Leo ');
INSERT into Tb_person
(Name, English_name, age, sex, birthday, description) values
(' Ivy son ', ' Avril Lavigne ', ' 24 ', ' Female ', ' 1984-09-27 ', ' Constellation: Libra ');
INSERT into Tb_person
(Name, English_name, age, sex, birthday, description) values
(' W. AXL Rose ', ' W. AXL Rose ', ' 45 ', ' Male ', ' 1962-02-06 ', ' GNR ');
INSERT into Tb_person
(Name, English_name, age, sex, birthday, description) values
(' Curtis ', ' Ian Curtis ', ' 50 ', ' Male ', ' 1956-07-15 ', ' Joy Division ');
INSERT into Tb_person
(Name, English_name, age, sex, birthday, description) values
(' Buffett ', ' Warren Buffett ', ' 78 ', ' female ', ' 1930-08-30 ', ' Stock ');
INSERT into Tb_person
(Name, English_name, age, sex, birthday, description) values
(' Bill Gates ', ' Bill Gates ', ' 18 ', ' Female ', ' 1955-10-28 ', ' Microsoft ');
drop table if EXISTS tb_book;--, if present, deletes tables Tb_person
CREATE TABLE Tb_book (--Creating tables
ID INTEGER auto_increment COMMENT ' id ',
person_id INTEGER,
Name VARCHAR COMMENT ' number ',
Publish_date date COMMENT ' publication dates ',
Description TEXT COMMENT ' remarks ',
Create_time TIMESTAMP DEFAULT current_timestamp () COMMENT ' creation time ',
PRIMARY KEY (ID)
);
Batch execution of SQL statements in MySQL