1. 程式人生 > >MySQL對資料表的基本操作語句

MySQL對資料表的基本操作語句

資料表的建立

create table user(
    id int not null auto_increment,
    username varchar(20) not null,
    gender char(1) not null default 'M',
    primary key(id)
);

檢視資料庫中所有的表

show tables;

查看錶的結構

describe table_name;   or  desc table_name;

向表中新增內容

insert into user(id,username,gender) values(1
,'xiaoD','M');

修改表的名字

alert table table_name rename table_new_name;

刪除表

drop table table_name;