mysql 建表,插入数据,建立索引,删除索引
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));
察
创建表 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 employee; 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'); 创建索引 建表时创建带索引的表 create table test1 (test1_id char(4)mysql表索引,name char(20), index idx_test1(name(10))); create index idx_employee on employee(name); 用create为name列创建索引 alter table products add index idx_products(name); 用alter为name列创建索引 察看索引 show index from employee; show index from products; 删除索引 drop index idx_employee on employee; alter table products drop index idx_products; (编辑:广州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |