MySQL basic syntax

create table if not exists table name (
column name column type (length) attribute index comment,

column name column type (length) attribute index comment,
) engine = engine name charset = "" comment;
-delete table
drop table table name;
– View table creation statement
show create table table name;
– View table structure
desc table name;
– Modify table
alter table table name;
3.5 External check constraints (to add constraints to fields)
– Add foreign key
create table table when creating table Name (
list of fields...,
[constraint index name] foreign key (fields of this table) references foreign table (foreign table fields);
);
-modify the foreign key when the table already exists
alter table table name add [constraint index name] foreign key ( Fields of this table) references
-delete foreign key
alter table table name drop foreign key index name,

4. Row-level operation (data operation)
-insert statement
insert into table name (field list) values ​​(corresponding field), ();
-modify statement
update table name set field name = value,..., field name = value where conditional statement ;

Guess you like

Origin blog.csdn.net/jokertiger/article/details/114028578