DB总结1
DBA 重构 data new york committee cobol codasyl journal
DDL DML 关系演算 域关系演算语言(QBE) 元祖关系演算语言(ALPHA)
查询语言其实本质是逻辑语言 聚集函数(内置函数) 象集
除运算(一定有相同的列)的结果是被除关系的某一行值(有时候是不能随便除)
SQL语句是大小写模糊的,并且分号模糊 模式包含数据库
为用户定义一个模式 约束条件在数据字典里
Create schema”S-T” authorization niu;
Drop schema”S-T” <cascade|restrict>
级联(全部删除) 限制(模式为空时删除)
Create table Student
(Sname char(9) primary key,
SAge smallint,
);
Numeric定点数 decimal
Foreign key Cpno references course(Cno) 外码主键
主码超过一个属性为主键时,必须用表级完整性约束定义
Create table”s-t”.student( );
修改表:
Alter tbale student
Add brithday date
Drop <完整性约束名>
Alter column sage int
Drop table student cascade;
建立索引: create (unique cluster聚族索引)index index1
On student( Sage 1
Sname 2
);
删除索引:drop index index1;
聚族索引:就是索引项的顺序与表中记录一致
索引建立在多列或是一列 ASC升 DEFC降
默认为ASC
Create unique index Scno on SC(Sno ASC,Cno DESC);
查询:
Select all|distinct *****
From student ** **
Where ***
Group by 列 hacing **
Order by 列 ASC|DESC;
Select *
Lower小写
可以加入字符串 select Sname ‘yourname:’ Sname
Select distinct Sno 就是取消重复的
<> 不等于 like where Sage<20
Where Butween**and ** not between**and**
Where Sage ( not) in(‘11’,’33’)
Not like ‘ ***’ escape ‘***’
%(通配符)——任意长度 _ 代表任意单个长度
Where Cname like’%牛’
Escape ‘\’ 转换字符
Where Cname like ‘ db\_Design ‘ escape’\’
空值查询 where grade is (not)null
多重查询用and
Group by grade,Sage DESC
聚集函数: count(distinct|all*)
Count(distinct|all Sage)
Sum(distinct|all Sage)
Avg(distinct|all Sage)
Max(distinct|all Sage)
Min(distinct|all Sage) 注意:都是无重复
Select Cno,count(Sno)
From SC
Group by Cno;按Cno分组
Having count(*)>3; 是分组聚集运算之后再选择
连接查询(多表查询)
Select first.Cno,second.CPno 自身连接
左外连接:
From student left( outer join) SC on(student.Sno=SC.Sno) 就不需要where
子查询里一般用in = 或是>=等
Select Sno,Cno
From SC x
Where Grade >=(select avg(Grade)
From SC y
Where y.Sno=x.Sno);
子查询里的 Any all
Where Sage <all (not)(exists)(返回真假)
(select Sage
Prom student
Where Sdept=’CS’)
And Sdept<>’CS’;
结果之间的union intersect交 except差
数据插入:
Insert
Into student ( 列 列 列 )
Value( 1 2 2)(或者这个可以是子查询的结果)
修改:
Updata student
Set Sage=22
Where ****
删除:
Delete
From student
Where ***
定义视图:
Create view student (列 列 列 )
AS 子查询
(With check option)
删除视图:
Drop view student cascade;
视图其他的和表一样,视图是表的镜像,可以灵活改变
2017 4.11 中国 兰州
DB总结1的更多相关文章
- Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part3:db安装和升级
Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part3:db安装和升级 环境:OEL 5.7 + Oracle 10.2.0.5 RAC 5.安装Database软件 5. ...
- VS15 preview 5打开文件夹自动生成slnx.VC.db SQLite库疑惑?求解答
用VS15 preview 5打开文件夹(详情查看博客http://www.cnblogs.com/zsy/p/5962242.html中配置),文件夹下多一个slnx.VC.db文件,如下图: 本文 ...
- ODBC、OLE DB、 ADO的区别
转自:http://blog.csdn.net/yinjingjing198808/article/details/7665577 一.ODBC ODBC的由来 1992年Microsoft和Syba ...
- Linux平台 Oracle 11gR2 RAC安装Part3:DB安装
四.DB(Database)安装 4.1 解压DB的安装包 4.2 DB软件安装 4.3 ASMCA创建磁盘组 4.4 DBCA建库 4.5 验证crsctl的状态 Linux平台 Oracle 11 ...
- SSRS ----环境配置,没有 ReportServer DB 怎么办?
今天项目进入报表开发阶段,按照习惯,打开报表管理器,发现提示下面的错误: 错误:报表服务器无法打开与报表服务器数据库的连接.所有请求和处理都要求与数据库建立连接. 这是怎么回事儿呢,经过排查,发现数据 ...
- mongo DB for C#
(1)Download the MongoDB C#驱动. http://www.nuget.org/packages/mongocsharpdriver/. (2) Add Reference to ...
- jBPM4.4 no jBPM DB schema: no JBPM4_EXECUTION table. Run the create.jbpm.schema target first in the install tool.
jBPM4.4 no jBPM DB schema: no JBPM4_EXECUTION table. Run the create.jbpm.schema target first in the ...
- oracle db link的查看创建与删除
1.查看dblink select owner,object_name from dba_objects where object_type='DATABASE LINK'; 或者 select * ...
- Gc.Db之循序渐进
距离上次写Gc.Db框架已经有一段时间了,最近默默对框架代码已经做了不少优化和功能,且已经提交至nuget,大家如果想使用此框架,可以通过nuget搜索:Gc.Db进行下载和安装包. 本篇文章主要是介 ...
- oracle Entity db.Database.SqlQuery ORA-01843: 无效的月份
原因是oracle的日期格式化格式和本地语言环境的日期格式不一致导致的. 一般情景为oralce格式为英文格式 本地服务器或者开发机的环境为中文环境. 使用Dbcontext 实例一般不会有问题. 但 ...
随机推荐
- 二叉搜索树-php实现 插入删除查找等操作
二叉查找树(Binary Search Tree),(又:二叉搜索树,二叉排序树)它或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值: 若它的 ...
- DEDE图集手工上传图片,加入水印
DEDE的图集手工上传图片,是一个非常好用的flash上传图片工具.但是如果我们希望上传的图片,带有自己网站指定的水印,却发现没有达到我们的要求--那么如果我们确实希望上传的图片,带有水印,怎么办?以 ...
- SQL内外连接的区别
项目当中,需要将SQL server中的部分数据导入mongo中,由于SQL是关系型数据库的原因,需要联合多表进行查询,因此,了解了下SQL中内外连接的相关概念,以作备注: 1.内联接(典型的联接运算 ...
- 【ubuntu】出现device not managed连接不上网络
ubuntu安装好后显示“device not managed” 1. 编辑/etc/NetworkManager/NetworkManager.conf: sudo gedit /etc/Netwo ...
- ASP.NET那点不为人知的事(一)
http://www.cnblogs.com/OceanEyes/archive/2012/08/13/aspnetEssential-1.html#_label0 我们上网时,在浏览器地址输入网址: ...
- 如何结合后台数据库 启动vue项目
一:连接数据库 1. 点击打开后输入密码 2.查看数据库 show databases; 3.创建数据库 create database jd; 删除数据库 drop database jd; 4.使 ...
- 粗看ES6之函数
标签: es6 javascript 箭头函数 ES6为了书写方便引入了函数的全新简写方式-箭头函数 <!DOCTYPE html> <html> <head> & ...
- Yesterday is history, tomorrow is a mystery, but today is a gift.
Yesterday is history, tomorrow is a mystery, but today is a gift.昨天已成历史,明天太过神秘,而今天是一份礼物.
- IE浏览器在线更新GitHub客户端
在IE中输入网址:http://github-windows.s3.amazonaws.com/GitHub.application
- <Android 基础(十)> FloatingActionButton
介绍 Source Code中的介绍如下: Floating action buttons are used for a special type of promoted action. They a ...