关于Oracle和PostgreSQL的schema

1.Oracle的schema


schema是一个逻辑概念。
一般而言,一个用户就对应一个schema,schema名一般等于用户名,作为该用户缺省的schema。

schema不能由用户创建,是在某个用户创建了第一个对象(表、视图等)之后才会创建一个schema,当且仅当该用户下存在对象的时候才会存在schema。oracle中的create schema语句不能创建schema:

CREATE SCHEMA
Purpose:Use the CREATE SCHEMA to create multiple tables and views and perform multiple grants in a single transaction.
To execute a CREATE SCHEMA statement, Oracle executes each included statement. If all statements execute successfully, Oracle commits the transaction. If any statement results in an error, Oracle rolls back all the statements.
Note:This statement does not actually create a schema. Oracle automatically creates a schema when you create a user (see CREATE USER). This statement lets you populate your schema with tables and views and grant privileges on those objects without having to issue multiple SQL statements in multiple transactions.

简单来说就是在单个事务中创建多个表,视图等,和执行多个赋权。如果所有的语句都成功就提交事务,有一个不成功就回滚,但是create schema语句并不创建一个schema。


oracle的schema定义是:
A schema is a collection of database objects (used by a user.). 
schema是被一个用户使用的数据库对象的集合。
Schema objects are the logical structures that directly refer to the database’s data.
schema是直接关联数据库数据的逻辑结构。
A user is a name defined in the database that can connect to and access objects.
用户是在数据库中定义,能连接和获取数据库对象的名字。
Schemas and users help database administrators manage database security.
架构和用户帮助数据库管理员管理数据库安全。

总结起来就是,schema是一个数据库中某个用户拥有的所有对象(表,视图等)的集合,名称一般和用户名相同。


2.PostgreSQL的schema
PostgreSQL的schema默认命名为public,如果不特别指定,PostgeSQL以public模式操纵各类数据库对象。
PostgreSQL可以在数据库中创建schema,语句为create schema "MySchema";
其和oracle的schema不同之处在于其名称,oracle的默认schema是和用户名同名的schema,而posgresql默认的是名为public的schema。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值