Oracle merge into语法简介
2017-11-07 00:00
288 查看
Oracle 9i开始引入了merge into 语法,可以同时对表进行update或insert操作。当然是基于某个条件之上。
语法示例如下:
可以这么理解:将u2合并入u1,条件为 u1.id = u2.id。当条件匹配时,执行update语句,当不匹配时,执行insert语句。
--------------------------------
操作索引相关sql
语法示例如下:
MERGE INTO user u1 USING (SELECT 1 AS id,2 AS name FROM dual) u2 ON (u1.id = u2.id) WHEN MATCHED THEN UPDATE SET u1.name = u2.name WHEN NOT MATCHED THEN INSERT (id,name) VALUES(u2.id,u2.name);
可以这么理解:将u2合并入u1,条件为 u1.id = u2.id。当条件匹配时,执行update语句,当不匹配时,执行insert语句。
--------------------------------
操作索引相关sql
select * from all_indexes where table_name='表名' and owner='用户名'; --查询某用户下某张表的所有索引 create index 索引名 on 表名 (列名) --创建索引 alter index 旧索引名 rename to 新索引名; --修改索引名称 ALTER INDEX 索引名 COALESCE; --合并索引 ALTER INDEX 索引名 REBUILD; --重建索引 DROP INDEX 索引名; --删索引 --查询表注释 select * from user_tab_comments where table_name='表名'; --user_tab_comments:table_name,table_type,comments --相应的还有dba_tab_comments,all_tab_comments,这两个比user_tab_comments多了ower列。 --获取字段注释: select * from user_col_comments where table_name='表名'; --user_col_comments:table_name,column_name,comments --查询表约束 select constraint_name from dba_constraints where table_name='表名'
相关文章推荐
- Oracle merge into语法简介
- Oracle的Merge into语法
- oracle的Merge into语法应用
- Oracle merge into delete语法
- Oracle MERGE INTO语法探究
- Oracle语法:merge into using
- Oracle merge into 语法
- ORACLE 的Merge Into语法 有则更新 无则插入
- 工作总结的 -- Oracle merge into 报错& Linux使用
- oracle merge into
- oracle merge into
- Oracle merge into介绍
- 在JAVA中使用Oracle的MERGE以及INSERT ALL语法
- MERGE INTO语法
- ORACLE MERGE INTO (2)
- Oracle Merge into详细介绍
- Oracle Merge Into 的用法详解实例
- oracle merge into
- oracle merge into 的用法详解+实例