当前位置:Gxlcms > mysql > mysql对表惯用操作

mysql对表惯用操作

时间:2021-07-01 10:21:17 帮助过:5人阅读

mysql对表常用操作 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 da

mysql对表常用操作
  1. 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;
  2. 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
  3. NEXTTWO:insert,updae,delete,select pass
  4. NEXTTHREE:alert:
    1.delete column
    ?alter talbe table drop column
    2.alert rename
    ?alter table table rename new_table
    3.alter drop primary key
    ?alter table 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 table add column_name type not null comment ''
    6.change column type
    ?alter table table change column_name new_column_name type not null comment ''
    7.alter index_name
    ?alter table table add colunm index_name(index_column_name)
    8.alter drop index emp_name
    ?alter table 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.

人气教程排行