随笔分类 -  orcle-SQL基础

oracle sql 行转列 unpivot的使用
摘要:测试数据create table userTest( id int ,name varchar(20), passwd int, score int, age int);insert into userTest values(1,'小明',111,67,21);ins... 阅读全文
posted @ 2017-08-24 10:35 2637282556 阅读(225) 评论(0) 推荐(0)
oracle case when 在sql中的使用
摘要:selectFullDepartmentName, YearBudget , SupplementaryBudget , TotalSum , BudgetDate, case jidu when 'JANUARYBUDG... 阅读全文
posted @ 2017-08-24 10:05 2637282556 阅读(318) 评论(0) 推荐(0)
只读事务
摘要:只读事务 1一个会话中,对该表x时间设置只读事务后,在这个会话中该表x时间后发生的事务变化,不显示出来。(即使其他会话X时间后有对该表进行数据DML操作) 2语法 set transaction read only 阅读全文
posted @ 2017-06-11 14:41 2637282556 阅读(164) 评论(0) 推荐(0)
事务+事务特性+提交事务+回滚事务+保存点
摘要:事务 1事务由一系列的相关的sql语句组成的最小逻辑工作单元 2oracle以事务为单位来处理数据,保证数据的一致性 3如果对事务进行提交,该事物的所有sql语句操作都会提交,成为数据库的永久组成部分 4如果事务遇到错误而被取消或者回滚,事务的所有sql语句操作都会被... 阅读全文
posted @ 2017-05-19 20:47 2637282556 阅读(286) 评论(0) 推荐(0)
merge语句
摘要:merge语句 可以指定对2个表执行合并操作 语法 merge into tableName1 using tableName2 on joinCondition when matched then update set …. when not match... 阅读全文
posted @ 2017-05-19 01:11 2637282556 阅读(169) 评论(0) 推荐(0)
表连接+内连接+等值连接+不等值连接+自然连接+using+外连接+ 左外连接+右外连接+全连接+自连接+交叉连接
摘要:表连接 from tableName1 join_type tableName2 【 on (join_condition)】 【join_type tableNameN on join_condition …..】 tableName1:表1 tableN... 阅读全文
posted @ 2017-04-25 11:31 2637282556 阅读(306) 评论(0) 推荐(0)
order By
摘要:对查询的结果进行排序,写在sql的最后面 语法 select 。。。 form where group by having order by 列名 desc|asc, 列名 desc|asc….. 阅读全文
posted @ 2017-04-24 09:49 2637282556 阅读(90) 评论(0) 推荐(0)
select 语法+别名的使用+连接运算符+distinct+where+like+转义字符+between+in
摘要:select 语法 select 【distinct | all 】{* | 表达式 | 【列名,列名,… 】} from {表名| 子查询 } 【别名】 【where condition】 【connect by condition 【start wit... 阅读全文
posted @ 2017-04-22 01:38 2637282556 阅读(245) 评论(0) 推荐(0)
删除数据
摘要:delete 【form 】【schema.】表名【where condition】 schema.:用户模式 例如 zhou.student condition:删除添加/表达式/字句删除案列1 删除案列2create table class( cno var... 阅读全文
posted @ 2017-04-20 16:22 2637282556 阅读(107) 评论(0) 推荐(0)
更新数据+获取行号+某行记录的地址+from字句
摘要:更新数据 语法 update 表名 set {列名 =值【,列名 =值,列名 =值….】 | 列名=(子查询)} 【where condition 】 获取行号 rownum:代表行号 某行记录的地址 rowid:某行记录的地址修改第一行的数据 from字句... 阅读全文
posted @ 2017-04-20 16:19 2637282556 阅读(98) 评论(0) 推荐(0)
插入数据
摘要:语法 1>insert into 表名【(列名,列名,列名…)】 values (值,值,值) 注意:值要和列名对应2>create table 表名【(列名,列名,列名…)】 as 子查询 create table peopel(id,name) as selec... 阅读全文
posted @ 2017-04-20 16:04 2637282556 阅读(92) 评论(0) 推荐(0)
删除表+闪回删除+查询数据字典+查看回收站删除的表+清空回收站
摘要:删除表 1.drop table 表名 删除表的所有数据和表结构 删除表的所有索引 删除的表无法恢复,除非备份 提交所有的挂起事务 基于该表的视图和别名依然存在,但无效2drop table 表名【cascade constraints】【purge】 oracle... 阅读全文
posted @ 2017-04-20 15:47 2637282556 阅读(139) 评论(0) 推荐(0)