Introduction to Database Schema

Source: Internet
Author: User

"Reference" from the Baidu Encyclopedia database schema, for the collection of database objects, a user generally corresponds to a schema. The official definition is as follows: A schema is a collection of the database objects (used by A user.). Schema objects is 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 Administra Tors manage database security. From the definition we can see that the schema is a collection of databases objects, in order to distinguish the various collections, we need to give this collection a name, these are the many similar user names that we see under the Enterprise Manager scheme node, These nodes, such as usernames, are actually a schema,schema containing various objects such as tables views sequences stored procedures synonyms indexes clusters and database Links A user typically corresponds to a schema the user's schema name equals the user name and is the default schema for that user. This is why we see the schema name as the database username under the Enterprise Manager scenario. The Oracle database cannot create a new schema, and to create a schema, it can only be solved by creating a user's method (although Oracle has the CREATE SCHEMA statement, it is not used to create a schema) Create a schema for this user with the same name as the user name while creating a user and as the default schema for that user. That is, the number of schemas is the same as the number of user, and the schema name corresponds to the user name one by one and the same, all we can call the schema as the user alias, although this is not accurate, but it is easier to understand some. A user has a default schema, whose schema name is equal to the user name, and of course a user can use other schemas. If we visit a table and do not indicate which schema the table belongs to, the system automatically adds the default Sheman name to the table.For example, when we access the database, we access the EMP table under the Scott user, and through the select from EMP in fact, this SQL statement is the complete notation of the select from Scott.emp. The full name of an object in the database is Schema.object, not user.object. Similar if we do not specify the schema of the object when creating the object, the schema of the object is the user's default schema. This is like a user with a default tablespace, but the user can also use other tablespaces, and if we do not specify a tablespace when we create the object, the object is stored in the default tablespace, and in order for the object to be stored in another table space, we need to specify the table space for the object when it is created. Sql> Grant DBA to scottsql> CREATE TABLE test (name char) 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> commitcommit complete.sql> conn system/managerconnected.sql> Select from TestName----------systemsql> alter session Set Current_schema = scott-change user Default schema name session altered.sql> Select From TestName----------scottsql> Select owner table_name from Dba_tables where Table_name=upper (' test ') owner Table_n Ame------------------------------------------------------------Scott Testsystem test--above this query is the basis for me to say the schema as the alias of the user. In practice, Shcema and useR is exactly the same, there is no difference, the user name can also appear where the schema name appears.

Introduction to Database schema

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.