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的更多相关文章

  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. ...

  2. VS15 preview 5打开文件夹自动生成slnx.VC.db SQLite库疑惑?求解答

    用VS15 preview 5打开文件夹(详情查看博客http://www.cnblogs.com/zsy/p/5962242.html中配置),文件夹下多一个slnx.VC.db文件,如下图: 本文 ...

  3. ODBC、OLE DB、 ADO的区别

    转自:http://blog.csdn.net/yinjingjing198808/article/details/7665577 一.ODBC ODBC的由来 1992年Microsoft和Syba ...

  4. 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 ...

  5. SSRS ----环境配置,没有 ReportServer DB 怎么办?

    今天项目进入报表开发阶段,按照习惯,打开报表管理器,发现提示下面的错误: 错误:报表服务器无法打开与报表服务器数据库的连接.所有请求和处理都要求与数据库建立连接. 这是怎么回事儿呢,经过排查,发现数据 ...

  6. mongo DB for C#

    (1)Download the MongoDB C#驱动. http://www.nuget.org/packages/mongocsharpdriver/. (2) Add Reference to ...

  7. 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 ...

  8. oracle db link的查看创建与删除

    1.查看dblink select owner,object_name from dba_objects where object_type='DATABASE LINK'; 或者 select * ...

  9. Gc.Db之循序渐进

    距离上次写Gc.Db框架已经有一段时间了,最近默默对框架代码已经做了不少优化和功能,且已经提交至nuget,大家如果想使用此框架,可以通过nuget搜索:Gc.Db进行下载和安装包. 本篇文章主要是介 ...

  10. oracle Entity db.Database.SqlQuery ORA-01843: 无效的月份

    原因是oracle的日期格式化格式和本地语言环境的日期格式不一致导致的. 一般情景为oralce格式为英文格式 本地服务器或者开发机的环境为中文环境. 使用Dbcontext 实例一般不会有问题. 但 ...

随机推荐

  1. cad 安装失败/出错/卸载 2018/2017/2016/2015/2013/2012

    AUTO Uninstaller 更新下载地址 1.选择CAD 2.选择版本 3.点击“开始卸载”

  2. 转:99%的人都理解错了HTTP中GET与POST的区别

    原贴来自:http://www.techweb.com.cn/network/system/2016-10-11/2407736.shtml GET和POST是HTTP请求的两种基本方法,要说它们的区 ...

  3. 动态资源不缓存 filter

    package com.itheima.web.filter; import java.io.IOException; import javax.servlet.Filter; import java ...

  4. Apache Beam的特点

    不多说,直接上干货! Apache Beam 有两大特点: 1.统一了数据批处理(batch)和流处理(stream)编程范式: 2.能在任何执行引擎上运行. 它不仅为模型设计.更为执行一系列数据导向 ...

  5. DEDE模板中如何运行php脚本和php变量的使用

    在使用dede模板的时候,经常会需要直接对dede数据库的底层字段进行处理,如果dede中没有相应的函数的时候,往往就需要我们想办法来处理了. 举例:我想取出数据表addonimages中的某一条记录 ...

  6. pat1093. Count PAT's (25)

    1093. Count PAT's (25) 时间限制 120 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CAO, Peng The strin ...

  7. JS获取元素属性、样式getComputedStyle()和currentStyle方法兼容性问题

    1. getComputedStyle()  方法获取到的是经过计算机/浏览器计算后的样式 getComputedStyle($("#div")).width; 兼容性:IE6 7 ...

  8. btfs

    以下都是举例说明: A. 使用fdisk命令对/dev/sdb进行分区 B. 先对/dev/sdb5和/dev/sdb6进行格式化, 文件系统为btrfs C. 使用btrfs filesystem ...

  9. intellijidea课程 intellijidea神器使用技巧 3-1 列操作

    Ctrl shift 右箭头 ==> 选中右边单词 ctrl shift alt L ==> 选中所有相同的字符 Ctrl alt L     ==> 格式化

  10. hibernate课程 初探一对多映射2-1 一对多映射简介

    1 在数据库中用主外键的形式实现一对多的映射关系 2 hibernate 在一方设置集合set,表示多方