日期:2014-05-16 浏览次数:20470 次
??
列出所有数据库信息:??show databases;
转到某个数据库:??????? use database_name;
列出某个数据库的所有表信息:?show tables;
创建数据库:????????????? CREATE DATABASE database_name;
创建数据库表:?????????? CREATE TABLE mytable (name VARCHAR(20), sex CHAR(1),
? ????????????????????????????????????????????????????????????????? birth DATE, birthaddr VARCHAR(20));
显示表结构:????????????? DESCRIBE mytable;
更改表名:???????????????? alter table table_name rename new_t;
添加列:??????????????????? alter table table_name add column column_name column_attributes;
删除列:??????????????????? alter table table_name drop column column_name;
创建索引:???????????????? alter table c_table add index (column_name1,column_name2);
????????????????????????????? alter table c_table add unique index_name(column_name);
????????????????????????????? alter table c_table add primary key(sid);
删除索引:???????????????? alter table c_table drop index column_name1;
更改列信息:????????????? alter? table t_table change c_1 c_1 varchar(200);
????????????????????????????? alter table t_table modify 1 c_1 varchar(200);
插入语句:?????????????????insert into table_name (c_1,c_2) values ('x1',1);
更新语句:???????????????? update table_name set c_1 =1 where c_2=3;
删除数据库/表:?????????drop table table_name;
?????????????????????????????drop database database_name;