Home > Database > Mysql Tutorial > body text

set

WBOY
Release: 2016-06-07 16:06:24
Original
1180 people have browsed it

SQL set echo on-----------------设置运行命令是是否显示语句 SQL set feedback on----------------设置显示“已选择XX行” SQL set colsep | -----------------设置列与列之间的分割符号 SQL set pagesize 10----------------设置每一页的行数 SQL SET SER

 SQL> set echo on-----------------设置运行命令是是否显示语句

  SQL> set feedback on----------------设置显示“已选择XX行”

  SQL> set colsep | -----------------设置列与列之间的分割符号

  SQL> set pagesize 10----------------设置每一页的行数

  SQL> SET SERVEROUTPUT ON-----------设置允许显示输出类似dbms_output.putline

  SQL> set heading on----------------设置显示列名

  SQL> set timing on-----------------设置显示“已用时间:XXXX”

  SQL> set time on------------------设置显示当前时间

  SQL> set autotrace on----------------设置允许对执行的sql进行分析

DBMS_METADATA.GET_DDL包可以得到数据库的对象的ddl脚本。如下(SQLPLUS中执行):
1.得 到一个表的ddl语句:

SET SERVEROUTPUT ON
SET LINESIZE 1000
SET FEEDBACK OFF
set long 999999 ------显示不完整
SET PAGESIZE 1000 ----分页
EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false); ---去除storage等多余参数SELECT DBMS_METADATA.GET_DDL('TABLE','TCC_NE_FRAME') FROM DUAL;

SELECT DBMS_METADATA.GET_DDL('TABLE','TCC_NE_SNAP') FROM DUAL;

2.得到一个用户下的所有表,索引,存储过程的ddl

SET SERVEROUTPUT ON
SET LINESIZE 1000
SET FEEDBACK OFF
set long 999999 ------显示不完整
SET PAGESIZE 1000 ----分页
---去除storage等多 余参数
EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false);

SELECT DBMS_METADATA.GET_DDL(U.OBJECT_TYPE, u.object_name)
FROM USER_OBJECTS u
where U.OBJECT_TYPE IN ('TABLE','INDEX','PROCEDURE');

3.得到所有表空间的ddl语句

SET SERVEROUTPUT ON
SET LINESIZE 1000
SET FEEDBACK OFF
set long 999999------显示不完整
SET PAGESIZE 1000----分页
---去除storage等多余参数

SELECT DBMS_METADATA.GET_DDL('TABLESPACE', TS.tablespace_name)
FROM DBA_TABLESPACES TS;


4.得到所有创建用户的ddlSET SERVEROUTPUT ON
SET LINESIZE 1000
SET FEEDBACK OFF
set long 999999------显示不完整
SET PAGESIZE 1000----分页
---去除storage等多余参数

SELECT DBMS_METADATA.GET_DDL('USER',U.username)
FROM DBA_USERS U;另外,若执行不了该包,则需要正确安装好相应的包。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template