search
HomeDatabaseOracleWhat is schema in oracle

In Oracle, schema is a collection of database objects; an Oracle user corresponds to a schema, and a schema can only be created by creating a user. The schema can be called an alias of user, that is, the schema name is the same as user. The names correspond and are the same.

What is schema in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

What is schema in oracle

Let’s take a look at their definitions first:

A schema is a collection of database objects (used by a user.) .

Schema objects are the logical structures that directly refer to the database's data.

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.

We can see from the definition that schema is a collection of objects. In order to distinguish each collection, we need to give this collection a name. These names are what we You can see many nodes similar to user names under the Enterprise Manager solution. These nodes similar to user names are actually a schema. The schema contains various objects such as tables, views, sequences, stored procedures, synonyms, indexes, clusters. , and database links.

A user generally corresponds to a schema. The user's schema name is equal to the user name and serves as the user's default schema. This is why we see that the schema names are all database user names under the Enterprise Manager scheme. A new schema cannot be created in the Oracle database. To create a schema, it can only be solved by creating a user (although there is a create schema statement in Oracle, it is not used to create a schema). When creating a user At the same time, a schem with the same name as the user name is created for this user and used as the user's default shcema. That is, the number of schemas is the same as the number of users, and the schema name corresponds to the user name one-to-one and is the same, so we can call the schema an alias of the user. Although this is not accurate, it is easier to understand.

A user has a default schema, and its schema name is equal to the user name. Of course, a user can also use other schemas. If we access a table without specifying which schema the table belongs to, the system will automatically add the default sheman name to the table. For example, when we access the database, we access the emp table under the scott user through select * from emp; In fact, the complete way of writing this SQL statement is select * from scott.emp. The full name of an object in the database is schema.object, not user.object. Similar to if we do not specify the schema of the object when creating an object, the schema of the object is the user's default schema. This is like a user having a default table space, but the user can also use other table spaces. If we do not specify a table space when creating an object, the object will be stored in the default table space. If we want the object to be stored In other table spaces, we need to specify the table space of the object when creating the object.

Ahem, having said so much, let me give you an example, otherwise, everything will be boring!

SQL> Gruant dba to scott
SQL> create table test(name char(10));
Table created.
SQL> create table system.test(name char(10));
Table created.
SQL> insert into test values('scott'); 
1 row created.
SQL> insert into system.test values('system');
1 row created.
SQL> commit;
Commit complete.
SQL> conn system/manager
Connected.
SQL> select * from test;
NAME
----------
system
SQL> ALTER SESSION SET CURRENT_SCHEMA = scott; --改变用户缺省schema名
Session altered.
SQL> select * from test;
NAME
----------
scott
SQL> select owner ,table_name from dba_tables where table_name=upper('test');
OWNER TABLE_NAME
------------------------------ ------------------------------
SCOTT TEST
SYSTEM TEST

--The above query is the basis for me to use schema as the alias of user. In fact, in terms of use, shcema is exactly the same as user. There is no difference. The user name can also appear where the schema name appears.

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of What is schema in oracle. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
什么是oracle asm什么是oracle asmApr 18, 2022 pm 04:16 PM

oracle asm指的是“自动存储管理”,是一种卷管理器,可自动管理磁盘组并提供有效的数据冗余功能;它是做为单独的Oracle实例实施和部署。asm的优势:1、配置简单、可最大化推动数据库合并的存储资源利用;2、支持BIGFILE文件等。

oracle怎么查询所有索引oracle怎么查询所有索引May 13, 2022 pm 05:23 PM

方法:1、利用“select*from user_indexes where table_name=表名”语句查询表中索引;2、利用“select*from all_indexes where table_name=表名”语句查询所有索引。

oracle全角怎么转半角oracle全角怎么转半角May 13, 2022 pm 03:21 PM

在oracle中,可以利用“TO_SINGLE_BYTE(String)”将全角转换为半角;“TO_SINGLE_BYTE”函数可以将参数中所有多字节字符都替换为等价的单字节字符,只有当数据库字符集同时包含多字节和单字节字符的时候有效。

Oracle怎么查询端口号Oracle怎么查询端口号May 13, 2022 am 10:10 AM

在Oracle中,可利用lsnrctl命令查询端口号,该命令是Oracle的监听命令;在启动、关闭或重启oracle监听器之前可使用该命令检查oracle监听器的状态,语法为“lsnrctl status”,结果PORT后的内容就是端口号。

oracle怎么删除sequenceoracle怎么删除sequenceMay 13, 2022 pm 03:35 PM

在oracle中,可以利用“drop sequence sequence名”来删除sequence;sequence是自动增加数字序列的意思,也就是序列号,序列号自动增加不能重置,因此需要利用drop sequence语句来删除序列。

oracle查询怎么不区分大小写oracle查询怎么不区分大小写May 10, 2022 pm 05:45 PM

方法:1、利用“LOWER(字段值)”将字段转为小写,或者利用“UPPER(字段值)”将字段转为大写;2、利用“REGEXP_LIKE(字符串,正则表达式,'i')”,当参数设置为“i”时,说明进行匹配不区分大小写。

oracle怎么查询数据类型oracle怎么查询数据类型May 13, 2022 pm 04:19 PM

在oracle中,可以利用“select ... From all_tab_columns where table_name=upper('表名') AND owner=upper('数据库登录用户名');”语句查询数据库表的数据类型。

Oracle怎么修改sessionOracle怎么修改sessionMay 13, 2022 pm 05:06 PM

方法:1、利用“alter system set sessions=修改后的数值 scope=spfile”语句修改session参数;2、修改参数之后利用“shutdown immediate – startup”语句重启服务器即可生效。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.