Batch execution of SQL statements in MySQL

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.