04-26mysql command (database operation level, table creation, table operation)

Precautions:

Symbols must be in English.

Database operation level:

Complete table building:

#Create a new table zuoye1;
drop table if exists zuoye1;
create table zuoye1(
    id int auto_increment not null, #Field name id, integer type, auto-increment, not null
    f1 float comment 'decimal type',
    f2 decimal(20,5) default 12.3, #data length 20, 5 decimal places, default value 12.3
    f4 varchar(20) comment 'string type, data length 20',
    id2 int, #intended as a foreign key of a table
    primary key(id), #id is set as the primary key, which is both a constraint and an index
    unique key(f1), #Set as a unique key, which cannot be repeated. It is both a constraint and an index
    key(f2), #just an index
    foreign key(id2) references set_test(id)
)
comment = 'This is a complete table building statement',
engine = MyIsam, #Table type
auto_increment = 1000; #Automatic growth starts from 1000

 Modify the table:

Add: alter table table name add [column] field name field type field attribute;
delete: alter table table name drop field name
change: alter table table name change original field name new field name new field type new field attribute;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324898240&siteId=291194637