![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
SQL
文章平均质量分 78
he_qiao_2010
Make a dent in my notebook... not in the universe
展开
-
二,SQL语句
数据类型定义:lchar(n). Fixed length character string, with user-specified length n.lvarchar(n). Variable lengthcharacter strings, with user-specified maximum length n.l int. Integer (a finite(有限的原创 2012-10-30 16:17:02 · 665 阅读 · 0 评论 -
数据库范式
我所理解的数据库的范式范式的作用,我想主要是在设计数据库的时候,用来约束表的种种属性,除了第一范式,其他的3类范式,应该都是用来避免产生不必要的冗余。第一范式:表中每个域必须是原子的,即每一列都是不可再分的数据项,而不能是集合,数组等。表中的每个域值,只能记录实体的一个属性或者某个属性的某个部分。(不能有表中表)【防止表中表】第二范式:在符合第一范式的情况下,必须要有主原创 2013-09-29 11:10:45 · 1206 阅读 · 0 评论 -
一,码
SQL中的几种码:SuperKey:超码Candidate key:候选码Primary Key:主码Foreign Key:外码数据库中什么是超码、候选码、主码?码是数据系统中的基本概念。所谓码就是能唯一标识实体的属性,他是整个实体集的性质,而不是单个实体的性质。它包括超码,候选码,主码。超码是一个或多个属性的集合,这些属性可以让我们在一个实体集中唯一地标识一个实体。原创 2012-10-30 16:07:45 · 935 阅读 · 0 评论 -
六、聚集函数
定义:Aggregate functionsare functions that take acollection (a set or multiset) of values as input and return a single value. 聚集函数就是将一系列的属性作为输入,然后输出单个值的函数。– Average: avg – Minimum: min – Maxim原创 2012-10-30 16:34:11 · 1316 阅读 · 0 评论 -
八、关系代数
l The relationalalgebra is procedural(过程化) query language Aset of operations, take one or two limited relations asinput and produce a new limited relation as output. Three types of operations原创 2012-11-05 13:53:01 · 929 阅读 · 0 评论 -
十一、事务
事务:A transaction is asequence of queries and update statements on DB, executed as a single, and arestarted implicitly(隐式地) and terminated(结束) by oneofcommit work(提交)or rollback/abort work.– Co原创 2012-11-03 18:51:06 · 622 阅读 · 0 评论 -
十、连接和视图
Join Expressionsselect * from student, takes where student.ID =takes.ID;=select * from student natural join takes; =select * from student join takes using (ID);=select * from原创 2012-10-31 20:11:40 · 751 阅读 · 0 评论 -
九、数据库的修改
l Deletion oftuples from a given relation (删除元组) l Insertion ofnew tuples into a given relation (插入新的元组) l Updatingvalues in some tuples in a given relation (修改某些元组的值) l Subquery canbe used in m原创 2012-10-31 20:09:03 · 832 阅读 · 0 评论 -
七、嵌套子查询
Nested Subqueries:A subquery is aselect-from-where expression that isnested within another query.(子查询是嵌套在另一个查询中的select-from-where表达式) 测试一个元组是否是某个集合中的元素,用 in , not in1.“Find allthe cou原创 2012-10-30 16:39:42 · 1141 阅读 · 0 评论 -
五、排序
Sorting:We may specify desc fordescending order(降序) or asc forascending order(升序), for each attribute;ascending order is the default. (默认升序) – Example: order by namedesc Can sorton m原创 2012-10-30 16:32:08 · 592 阅读 · 0 评论 -
四、集合操作
l Find coursesthat ran in Fall 2009 or in Spring 2010 (select course_idfrom section where sem = ‘Fall’ and year = 2009) union (select course_idfrom section where sem = ‘Spring’ and year = 2010)原创 2012-10-30 16:31:20 · 609 阅读 · 0 评论 -
三、字符串运算
%用来匹配任何字符串;_下划线用来匹配任何单个字符;字符串一般用单引号' '括起来;一般字符串运算会与like操作一起用;对于特殊字符会用到\进行转义; +(字符串串联)+=(字符串串联)%(通配符 - 需匹配的字符)[ ](通配符 - 需匹配的字符)[^](通配符 - 无需匹配的字符)_(通配符 - 匹配一个字符) 这样可以表达原创 2012-10-30 16:29:44 · 813 阅读 · 0 评论 -
Oracle对没有主键的表分页
一般情况对于有主键,能够做唯一表识的表,我们可以利用主键和rownum配合实现,例如:select scott.emp.* from scott.emp left join (select empno id, rownum num from scott.emp) id_num on scott.emp.empno = id_num.id where id_nu原创 2015-07-22 23:53:37 · 1616 阅读 · 0 评论