当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
2015年全国计算机等级考试二级VFP辅导笔记:SQL语言
发布时间:2010/10/11 11:36:17 来源:城市学习网 编辑:ziteng
  第五章 SQL语言
  1、SQL:
  2、定义:是结构化查询语言,是关系数据库的标准语言,是一种高度非过程化的语言,是数据库后台操作语言,具有非常强大的查询功能,查询时它的核心。
  3、基本构成:select 查询什么 from 从哪来 where 查询条件
  4、三大功能:
  l 数据查询
  ①.格式:select 字段名/表名/* from 表1 inner join 表2 on 表1主关键字=表2主关键字 where 筛选条件[group by (按……分组)having(限定分组条件)order by(按……排序
  ②.函数
  最大值
  最小值
  求平均值
  统计
  求和
  ③.值域查询: between…and…
  ④.空值查询:
  ⑤.模糊查询:$ (后包前
  l 操作功能
  ①.插入 insert into 表名
  ②. 更新 update 表名 set 字段=表达式 where 条件
  ③.删除 delete from 表名 where 条件
  l 定义功能
  ①.表的定义
  ②. 删除表 drop table表名
  删除视图
  ③.表结构的修改
  ⑴.添加字段:alter table 表名add 字段名 类型(长度
  ⑵.删除字段:alter table 表名 drop 字段名
  ⑶.修改字段:alter table 表名 alter 字段名 新类型(长度
  ⑷.重新命名字段:alter table 表名 rename 旧字段名 to 新字段名
  ⑸.建立有效性规则:alter table 表名(数据库表)alter 字段 set check 字段条件
  ⑹.删除有效性规则:alter table 表名alter 字段
  ⑺.建立默认值:alter table 表名 alter 字段 set default 条件
  ⑻.删除默认值:alter table 表名 alter 字段
  ⑼.建立唯一索引:alter table 表名add unique 字段 tag索引名
  ⑽.删除唯一索引:alter table 表名drop unique tag 索引名
  ⑾.建立主索引:alter table 表名add primary key字段 tag索引名
  ⑿.删除主索引:alter table 表名drop primary key字段 tag索引名
  ⒀.建立普通索引:alter table 表名add foreign key字段 tag索引名
  ⒁.删除普通索引:alter table 表名drop foreign key tag索引名
  语句
  语句
  主索引
  黄钥匙表示
  候选索引
  唯一索引
  普通索引
  默认
  5、SQL的六种去向:
  ⑴.将查询结果保存到永久表:into table/dbf 表名
  ⑵.将查询结果保存到临时表:into cursor表名
  ⑶.将查询结果保存到数组:into array 数组名
  ⑷.将查询结果保存到文本文件:to file 文本文件名
  ⑸.将查询结果预览显示:
  ⑹.将查询结果打印:
  6、约束规则:
  7、量词查询:some any all (any、some是同义词
  * some、any 只有子查询中有一行能使结果为真,则结果为真
  * all 子查询中所有记录都使结果为真,则结果为真。
  8、谓词查询 exists not exists 用来检查是否有结果返回,即存在/不存在元组
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved