Mysql commonly used NEXTONE: createcreatetabletesttable (idint (10) notnullauto_incrementprimarykeycomment, namevarchar (20) notnullcharactersetutf8comment, age? Intnullcomment, genderchar (2) coment, gmt_createdda
Mysql commonly used operations on tables NEXTONE: create table testtable (id int (10) not null auto_increment primary key comment '', name varchar (20) not null character set utf8 comment '', age? Int null comment '', gender char (2) coment'', gmt_created da
Common mysql operations on tables
- NEXTONE: create
Create table testtable (
Id int (10) not null auto_increment primary key comment '',
Name varchar (20) not null character set utf8 comment '',
Age? Int null comment '',
Gender char (2) coment '',
Gmt_created datetime not null comment''
) Engine = innoDB default charset = utf8;
- Set the increment sequence: auto_increment
Set the primary key: primary key
Label: comment.
Set the field is not empty: not null
Set the field be empty: null
Format: character set utf8
Char fixed length variable length, varchar
Time type: datetime
- NEXTTWO: insert, updae, delete, select pass
- NEXTTHREE: alert:
1. delete column
? Alter talbe table drop column
2. alert rename
? Alter table rename new_table
3. alter drop primary key
? Alter table drop primary key
4. alter add primary key
? Alter table sj_resource_charges add constraint pk_sj_resource_charges primary key (resid, resfromid)
5. add column
? Alter table add column_name type not null comment''
6. change column type
? Alter table change column_name new_column_name type not null comment''
7. alter index_name
? Alter table add colunm index_name (index_column_name)
8. alter drop index emp_name
? Alter table drop index index_column_name
NEXTFOUR:
Drop
Structure of the drop statement will delete tables are dependent constraints (constrain), trigger (trigger), index (index) depends on the table;
The stored procedure/function will be retained, but to the invalid state.