mysql 建表,改表結(jié)構(gòu),插入數(shù)據(jù),建立索引,刪除索引
創(chuàng)建表
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));
察看表結(jié)構(gòu)
describe employ-ee;
describe products;
修改表結(jié)構(gòu)
alter table employee modify name char(10);
alter table products modiry name char(30);
向表中添加數(shù)據(jù)
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');
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');
修改表內(nèi)容
update employee set employee_id="200310" where name="zhaoliu";
創(chuàng)建索引
建表時(shí)創(chuàng)建帶索引的表
create table test1 (test1_id char(4),name char(20), index idx_test1(name(10)));
create table test1 (test1_id char(4),name char(20), index idx_test1(name(10)));
create index idx_employee on employee(name); 用create為name列創(chuàng)建索引
alter table products add index idx_products(name); 用alter為name列創(chuàng)建索引
察看索引
show index from employee;
show index from products;
show index from products;
刪除索引
drop index idx_employee on employee;
alter table products drop index idx_products;
posted on 2009-01-08 17:13 liyang 閱讀(934) 評論(0) 編輯 收藏 所屬分類: mysql