一、sql基本表创建、修改、删除语句
创建模式 create schema 创建表 create table 创建视图 create view 创建索引create index
相对应删除为 drop table/view......
修改表 alter table 创建的其他项没有修改操作
例如--》
alter table Student add S_ontrance date; /*学生表增加入学时间列*/
alter table Student alter column Sage int; /*修改学生表的Sage列的数据类型为int,这个在mysql中执行错误*/
alter table Course add unique(Cname); /*增加课程名唯一的约束*/
alter table 表名 drop constraint 约束名
删除表 drop table <表名> [restrict(有限制) | cascade(无限制)]
建立索引 create [unique] [cluster] index <索引名称> on <表名>(<列名>[<次序>][,<列名>[<次序>]]...));索引可建立在一列或多列上
次序:ASC升 / DESC降 例==》
create unique index StuNoIndex on Student(Sno);[]里所包含的内容可有可无
unique表示此索引的每一个索引值只对应唯一的数据记录。
cluster表示要建立的索引是聚簇索引。聚簇索引确定表中数据物理顺序。类似电话簿,后者按姓氏排列数据
非聚集索引,该索引的逻辑顺序与磁盘上行的物理存储顺序不同,创建一个索引表
默认是普通索引
对聚集与非聚集的
创建模式 create schema 创建表 create table 创建视图 create view 创建索引create index
相对应删除为 drop table/view......
修改表 alter table 创建的其他项没有修改操作
例如--》
alter table Student add S_ontrance date; /*学生表增加入学时间列*/
alter table Student alter column Sage int; /*修改学生表的Sage列的数据类型为int,这个在mysql中执行错误*/
alter table Course add unique(Cname); /*增加课程名唯一的约束*/
alter table 表名 drop constraint 约束名
删除表 drop table <表名> [restrict(有限制) | cascade(无限制)]
建立索引 create [unique] [cluster] index <索引名称> on <表名>(<列名>[<次序>][,<列名>[<次序>]]...));索引可建立在一列或多列上
次序:ASC升 / DESC降 例==》
create unique index StuNoIndex on Student(Sno);[]里所包含的内容可有可无
unique表示此索引的每一个索引值只对应唯一的数据记录。
cluster表示要建立的索引是聚簇索引。聚簇索引确定表中数据物理顺序。类似电话簿,后者按姓氏排列数据
非聚集索引,该索引的逻辑顺序与磁盘上行的物理存储顺序不同,创建一个索引表
默认是普通索引
对聚集与非聚集的