Schema in Oracle DB

Source: Internet
Author: User


The Schema SQL code www.2cto.com in Oracle DB is officially defined as follows: 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. from the definition, we can see that schema is a set of database objects. To distinguish each set, we need to name this set, these names are the nodes with similar user names that we see in the Enterprise Manager Solution. These nodes with similar user names are actually a schema, 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 schema name of the user is the same as the user name and serves as the user's default schema. This is why the schema names are database usernames in the Enterprise Manager Solution. You cannot create a new schema in an oracle database. To create a schema, you can only create one user, but it is not used to create a schema). When creating a user, create a schem with the same name as the user name and use it as the default shcema for the user. That is to say, the number of schemas is the same as the number of users, and the schema names are one-to-one and the same as the names of users. All aliases that can be called schema as users are inaccurate, but it is easier to understand. A user has a default schema, and Its schema name is the same as 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 can access the emp table under the scott user and use the select from emp statement to write the entire SQL statement as select from scott. emp. The full name of an object in the database is schema. object, not user. object. Similarly, if we do not specify the schema of the object when creating the object, the schema of the object is the default schema of the user. This is like a user has a default tablespace, but this user can also use other tablespaces. If we do not specify a tablespace when creating an object, the object is stored in the default tablespace, to store objects in other tablespaces, We need to specify the tablespace of the object when creating the object. Www.2cto.com 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 complete. SQL> conn system/manager connected. SQL> select from test name ---------- system SQL> alter session se T current_schema = scott -- change the user's default schema name 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 preceding query is the basis for using schema as the alias of the user. In fact, shcema is exactly the same as the user, and there is no difference. The user name can also appear in the place where the schema name appears.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.