[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博客 ” ,链接:https://blog.itpub.net/267265/viewspace-721510/
,如需转载,请注明出处,否则将追究法律责任。