CREATE TABLE t1(
id int not null,
name char(20)
);
创建表
create table employee (employee_id char(6) primary key,name char(8),sex char(2),birthday(date);
create table products (product_id char(2) primary key, name char(20));
察看表结构
describe employ-ee;
describe products;
向表中添加数据
insert into employee values (’200301’,’zhangsan’,’m’,’1978/5/8’);
insert into employee values (’200302’,’lisi’,’f’,’1973/3/20’);
insert into employee values (’200303’,’wangwu’,’f’,’1970/10/9’);
insert into employee values (’200304’,’zhaoliu’,’m’,’1975/1/18’);
创建索引
建表时创建带索引的表
1
create table test1 (test1_id char(4),name char(20), index idx_test1(name(10)));
2
create index idx_employee on employee(name); 用create为name列创建索引
3
alter table products add index idx_products(name); 用alter为name列创建索引
察看索引
show index from employee;
show index from products;
删除索引
1
drop index idx_employee on employee;
2
alter table products drop index idx_products;