免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1687 | 回复: 1
打印 上一主题 下一主题

oracle for the lazy people (1) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-01-01 04:15 |只看该作者 |倒序浏览
Have Oracle to write what you want.

Example 1)

If you want to create a table but do not know how, have oracle write the SQL for you.

-----
set long 4000
set pagesize 0
connect scott/tiger
select dbms_metadata.get_ddl('TABLE', 'EMP')
from dual;
-----

The SQL will return the SQL that creates the emp table in scott's schema.  Learn the SQL, modifiy and use it in your own work.

  CREATE TABLE "SCOTT"."EMP"
   (    "EMPNO" NUMBER(4,0) NOT NULL ENABLE,
        "ENAME" VARCHAR2(10),
        "JOB" VARCHAR2(9),
        "MGR" NUMBER(4,0),
        "HIREDATE" DATE,
        "SAL" NUMBER(7,2),
        "COMM" NUMBER(7,2),
        "DEPTNO" NUMBER(2,0)
   ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
  TABLESPACE "DATA"

Example 2)

Show us how scott  create the index on his emp table.
-----
set long 4000
set pagesize 0
select dbms_metadata.get_dependent_ddl('INDEX', 'EMP', 'SCOTT')
from dual;
-----

Example3)

Show us how tablespace data is created:

-----
set long 4000
set pagesize 0
select dbms_metadata.get_ddl('TABLESPACE', TABLESPACE_NAME)
from dba_tablespaces
where tablespace_name = 'DATA';
-----

  CREATE TABLESPACE "DATA" DATAFILE
  '/oracle/920/oradata/db920/data_1.dbf' SIZE 10485760 REUSE
  AUTOEXTEND ON NEXT 4096 MAXSIZE UNLIMITED
  LOGGING ONLINE PERMANENT BLOCKSIZE 4096
  EXTENT MANAGEMENT LOCAL AUTOALLOCATE SEGMENT SPACE MANAGEMENT MANUAL

Now you can start to learn what is means, modify it and use it in your own work.

论坛徽章:
0
2 [报告]
发表于 2005-01-01 04:21 |只看该作者

oracle for the lazy people (1)

Exampe 1) and 2)
connect scott/tiger
Example 3)
connect / as sysdba
if you remove the "where" clause you get the DDLs for all tablespaces in the system.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP