ORACLE 使用DBMS_METADATA.GET_DDL获取DDL语句
Oracle 在9i以后,可以利用DBMS_METADATA.GET_DDL包得到数据库的对象的ddl脚本。如下(SQLPLUS中执行):
1. 获取单个的建表、视图和建索引的语法
set pagesize 0
set long 90000
set feedback off
set echo off
spool DEPT.sql
select dbms_metadata.get_ddl('TABLE','TAB_NAME','SCOTT') from dual;
select dbms_metadata.get_ddl('VIEW','VIEW_NAME','SCOTT') from dual;
select dbms_metadata.get_ddl('INDEX','IDX_NAME','SCOTT') from dual;
spool off;
2. 获取一个SCHEMA下的所有建表、视图和建索引的语法,以scott为例:
set pagesize 0
set long 90000
set feedback off
set echo off
spool schema.sql
connect scott/tiger;
SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name) from USER_TABLES u;
SELECT DBMS_METADATA.GET_DDL('VIEW',u.VIEW_name) from USER_VIEWS u;
SELECT DBMS_METADATA.GET_DDL('INDEX',u.index_name) from USER_INDEXES u;
spool off;
3. 获取某个SCHEMA的建全部存储过程的语法
set pagesize 0
set long 90000
set feedback off
set echo off
spool procedures.sql
select DBMS_METADATA.GET_DDL('PROCEDURE',u.object_name) from user_objects u where object_type = 'PROCEDURE';
spool off;
4. 获取某个SCHEMA的建全部函数的语法
set pagesize 0
set long 90000
set feedback off
set echo off
spool function.sql
select DBMS_METADATA.GET_DDL('FUNCTION',u.object_name) from user_objects u where object_type = 'FUNCTION';
spool off;
相关文档:
select d.code,d.name, sum(w.weight) weight,round(avg(w.price),2) price,sum(w.money) money
from weight_info w left outer join t_dict d on w.productcode=d.code left outer join t_balancecode b on w.balancecode=b.balancecode where 1=1 and w.operdate>TO_TIMESTAMP('2009-11-2 04:12:32.0', ' ......
配置文件:
<hibernate-mapping>
<class name="vo.SshPost" table="ssh_post" >
<!-- <cache usage="read-write"/>-->
<id name="postId" type="java.lang.String">
......
Step1. Insert empty_clob() into the Clob column of Oracle
Step2. Set autocommit to false
Step3. Select Clob as oracle.sql.CLOB from database
Step4. Insert String into Clob
Step5. Commit
Example:
import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.OracleResultSet;
......
单行函数:
函数类别:
单行:返回单个结果:substr,length
多行:返回多个结果,any,all
单行的分类:
字符类,日期类,数字类,转换类,通用类
1.字符类
转换大小写:
lower:转换为小写
Select ENAME,LOWER(ENAME) from EMP
upper:转换为大写
Select upper( ......
转载
from: http://cid-4e5d038451e31a25.spaces.live.com/blog/cns!4E5D038451E31A25!140.entry
create or replace procedure P_QuerySplit(
sqlscript varchar2, --表名/SQL语句
pageSize integer, ......