>데이터 베이스 >MySQL 튜토리얼 >mysql对表惯用操作

mysql对表惯用操作

WBOY
WBOY원래의
2016-06-07 16:15:461049검색

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.
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.