MySQL database (b) - the library, the basic operation table

(A) Operating SQL database format:

1. Create a database

create database database_name;

2, view the database

show databases;

3, using the database

use database_name;

4, there is a table under the View database

show tables;

5, delete the database

drop database database_name;

(Ii) operations SQL table format

1, create a table

create table table_name (attribute name Data type [integrity constraints], property name data type 2 [integrity constraints], 3 Attribute Name Data Type [integrity constraints]);

(*)type of data:

(*) Integrity constraints:

2, view the table

(1)desc table_name;

(2)show create table table_name;

3, modify table (ALTER)

(1) modify the table name

alter table old_table_name rename [to] new_table_name;

(2) modifying a table fields (attributes)

alter table table_name change the old name of the new attribute name attribute new attribute type;

(3) modify the data type of the attribute table

alter table table_name modify Attribute Name Attribute Type;

(4) increase the field table

alter table table_name add Attribute Name Attribute Type [integrity constraint];

(5) removing fields

alter table table_name drop attribute name;

(6) to modify the order of the fields

alter table table_name modify a property attribute type first | after 2 attribute;

(7) modify the storage engine

alter table table_name engine = InnoDB | myISAM;

 

Guess you like

Origin blog.csdn.net/weixin_42479293/article/details/94722407