您的位置:首页 > 数据库

[置顶] sql学习日志1

2017-10-12 18:07 477 查看
select 

create drop alter

insert update delete

grant revoke

create schema __ drop schema __  创建模式

create table  __ drop table  __ alter table 创建删除修改表

create view   __ drop view 视图

crate index   __ drop index 索引

create schema "S-T" authorization Wang 

caeate schema authorization Wang

drop schema Wang cascade 无限制删除

cascade cascade cascade

restrict 限制

caeate table student

(Sno char(9) primary key,

Sname char(20) unique,

);

alter table Student add s_entrence date 增加属性列

alter table Student alter column Sage int 改变列的数据类型

alter table Course add unique(Cname) 增加唯一性约束

restrict

create cluster index Stusname on Student(Sname) // 聚簇索引

create unique index Stusno on Student(Sno)  //默认升序建立索引

create unique index SCno on SC(Sno asc, Cno desc) //Sno 升序 Cno 降序

drop index Stusno
distinct

创建视图

create view is_student

AS

select sno, sname, sage

from student

where sdept = 'is';

drop table student restrict; //限制删除基本表

creat cluster index stuname on student(sname) 建立聚簇索引

一个基本表只能建立一个聚簇索引,建立索引为了提高查询效率

drop index stuname;

select distinct sno from SC 消除重复的行

降序排列 order by子句

select sno, grade

from SC

where cno = '3'

order by grade desc

count sum avg max min 聚集函数
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: