SQL语句
1.数据库
mysql -u root -p 回车后输入 密码
show databases;
create database test;
drop database test;
use test;
show tables;
create table 表名 (字段1 类型, 字段2 类型);
desc 表名;
drop table 表名;
show create database 库名;
show create table 表名;
2. 表
ALTER TABLE t1 ENGINE = InnoDB;
ALTER TABLE t1 AUTO_INCREMENT = 13;
ALTER TABLE t1 CHARACTER SET = utf8;
ALTER TABLE t1 COMMENT = 'New table comment';
ALTER TABLE t1 RENAME t2;
3.字段
ALTER TABLE `table` ADD INDEX `idx_updateTime`(`updated_time`) USING BTREE;
ALTER TABLE t1 ADD COLUMN col1 int(11) COMMENT '备注' AFTER `id`;
ALTER TABLE `t1 DROP COLUMN col1;
ALTER TABLE t1 MODIFY col1 VARCHAR(30);
ALTER TABLE t1 CHANGE col1 col2 VARCHAR(30);
4.索引
alter table t1 add index index_name (column_list) USING BTREE COMMENT '备注';
alter table t1 add unique (column_list) USING BTREE COMMENT '备注';
alter table t1 add primary key (column_list) USING BTREE COMMENT '备注';
alter table t1 drop index index_name;
alter table t1 drop primary key;
|