Home > Database > Mysql Tutorial > mysql对表惯用操作

mysql对表惯用操作

WBOY
Release: 2016-06-07 16:15:46
Original
1054 people have browsed it

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.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template