RelationalDBDesignRelationalDBDesign




Physical Design   «Prev  Next»
Lesson 12Using SQL to create a Database
Objective Explain how to create a database with SQL.

Using SQL to create a Database

Now that you have created a physical design for the database, it is time to move to the fourth stage of the DBLC: implementation [1]. In this phase of the DBLC, you will useSQL[2] to create the database to hold your tables, then create the tables themselves.
The specific commands used to create a database may vary from system to system. The procedure described below will apply to every RDBMS, but the commands may be slightly different.



Creating a database with SQL


When you create a database, you create a container for the tables and views you want to build. The technical name for that container is a schema. To create a schema, you use the SQL CREATE SCHEMA statement, followed by the name of the schema you want to create. For example:
CREATE SCHEMA StoriesOnCDOrders
If the schema you want to work with already exists, you can use the SQL SET SCHEMA command to let the RDBMS know you want to add tables to the database. For instance, the following command will open the StoriesOnCDOrders schema (database) for editing:
SET SCHEMA StoriesOnCDOrders

The next lesson explains how to create tables with SQL.
[1] implementation: Using SQL to create a database; the fourth step in the database life cycle.
[2] SQL: SQL is an acronym for Structured Query Language. It provides a set of commands that can be used to add data to a database, retrieve that data, and update it. SQL, often pronounced “sequel”, is universally supported by relational database vendors.