2

I'm having trouble determining the difference between CREATE SCHEMA and CREATE DATABASE. I'm of the understanding that they are the same and that it's usual to use the latter.

Is that so?

Thanks!

4 Answers 4

5

They are definitely not that same! A database may consist of several schemas. Schemas are basically securable objects that can contain other securable objects such as tables, views, procedures etc. Securable in this context means something that is owned by someone and to which operations can be granted.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks very much everyone - that helps to clarify!
So, to clarify that my understanding is correct: An SQL schema can be thought of a particular viewpoint of a database, e.g. admininstrator (see's all tables, views, procedures), manager (sees employee-related tables, etc.), trainee (sees only basic tables, etc.)? i.e. the user-view level of the 3-tier ANSI/SPARC architecture? Or am I still misunderstood? Many thanks!
No a schema can be thought of as a container inside a database. So a database is a container that can contain schemas and users (and possibly groups). A schema is a container that can contain a large number of different objects, such as tables, views, procedures etc. A schema is owned by a user (or group), but other users/groups can be granted the right to use the objects contained in the schema.
1

In MySQL, the two commands are synonymous from 5.0.2 upwards - this is perhaps why you had the understanding they were the same.

http://dev.mysql.com/doc/refman/5.0/en/create-database.html

However, as the others have mentioned, Schemas and Databases are different types of entity in other RDBMS.

1 Comment

Ah thank you, that is helpful! That explains my confusion with equality. Much appreciated!
0

CREATE schema is to create a schema above the database. So can a CREATE SCHEMA create tables, views, etc etc.

CREATE SCHEMA can't create a database.

Comments

0

Create schema creates new schema while create database creates database. See this link for more information about schemas: User-Schema Separation

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.