Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1724666
  • 博文数量: 293
  • 博客积分: 10574
  • 博客等级: 上将
  • 技术积分: 5085
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-22 17:00
文章分类

全部博文(293)

文章存档

2011年(27)

2010年(84)

2009年(62)

2008年(120)

我的朋友

分类: Mysql/postgreSQL

2008-11-06 17:11:43

创建表
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;
 
修改表结构
alter table employee modify name char(10);
alter table products modiry name char(30);

向表中添加数据
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');
 
修改表内容
update employee set employee_id="200310" where name="zhaoliu";

创建索引
建表时创建带索引的表
create table test1 (test1_id char(4),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;
阅读(1272) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~