1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
查看 show tables (from database1); show colunms from table1; desc table1; show create table table1; 创建 create table table_name ( 列名 类型 约束; 列名 类型 约束; ); 例: create table student ( name varchar(10); age tinyint; ); 添加列,改列名,改列类型,改列位置,删除列 alter table table1 add colunm1 类型 (after colunm2//指定位置,不指定默认最后一列); alter table table1 change colunm1 colum2 类型; alter table table1 modify colunm1 类型2; alter table table1 modify colunm1 类型 after colunm2; alter table table1 drop colunm1; 删除表,修改表名 dorp table table1, table2; rename table info to info2; alter table table1 rename table2; 表分区 show plugins//查看是否只是表分区 例子 create table student ( name varchar(10); age tinyint; partition by range(age) ( partition p1 less than (40) ) ); 检索p1内的数据 select * from table2 partiton(p1); |