1.基本表中的数据插入与修改,删除
(1)数据插入
1》.insert into 表名 values (值1,值2,......), insert into course values (101,"math",2);
2》.insert into 表名 (属性列表)values (取值列表1),(取值列表2),..... insert into course(cno,cname.credit) values(101,"math",2),(102,"china",3);
3》..insert into 表名 values (取值列表1),(取值列表2),..... insert into course values(101,"math",2),(102,"china",3);
(2)数据修改
update 表名 set 列名=表达式【列名=表达式.....】where 条件 ,update student set sname="jerry" where sno =2015;
(3)数据删除
delete from 表名 where 条件,delete from customer where custname="张小宁";
2.索引的建立和删除
(1)创建索引
1》.在已经存在表中创建索引
create [unique] [clustered] index 索引名 on 表名(列名[次序],列名[次序].....)
create unique index idx_custphone on Customer(custphone);
2》.创建表时创建索引
create table 表名(
属性名 数据类型 [完整性约束条件],
属性名 数据类型 [完整性约束条件]
...
[unique|fulltext|spatial] index|key [别名](属性名1 [(长度)] [asc|desc]))
create table index1(id int,name varchar(5),index(id));
3》. 用alter table语句创建索引
alter table 表名 add [unique|fulltext|spatial] index 索引名 (属性名 [(长度)] [asc|desc]);
alter table tb add index name(id);
(2)删除索引
alter table 表名 drop index 索引名;
drop index 索引名 on 表名;
alter table student drop index mna;