ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [20120418]CREATE SCHEMA.txt

[20120418]CREATE SCHEMA.txt

原创 Linux操作系统 作者:lfree 时间:2012-04-18 11:43:31 0 删除 编辑
[20120418]CREATE SCHEMA.txt

CREATE SCHEMA
Purpose
    Use the CREATE SCHEMA statement to create multiple tables and views and perform.
multiple grants in your own schema in a single transaction.
To execute a CREATE SCHEMA statement, Oracle Database executes each included
statement. If all statements execute successfully, then the database commits the
transaction. If any statement results in an error, then the database rolls back all the
statements.

schema
    Specify the name of the schema. The schema name must be the same as your Oracle Database username.

例子:

SQL>create schema authorization scott
    create table testa1(id number,name varchar2(10))
    create table testa2(id number,name varchar2(10));

Schema created.

如果中间报错,建立的对象无效。

SQL> drop table testa1 purge;
SQL> drop table testa2 purge;

SQL> create schema authorization scott
create table testa1(id number,name varchar2(10))
create index i_testa1_id on testa1(id);

ORA-02422: missing or invalid schema element

SQL> desc testa1;
ERROR:
ORA-04043: object testa1 does not exist

--按照文档介绍仅仅支持create table,create view,grant语句,其它不支持(像建立索引)。

如果修改前面如下:
create schema authorization scott
    create table testa1(id number,name varchar2(10))
    create table testa2(id number1,name varchar2(10));

--写错number为number1.提示如下:

ERROR at line 3:
ORA-02425: create table failed
ORA-00902: invalid datatype


SQL> desc testa1
ERROR:
ORA-04043: object testa1 does not exist


--可以发现表testa1没有建立成功!


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-721510/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    2286
  • 访问量
    6026410