Create Database SQL Query

SQL Create Database

When we get a requirement for a database project, even before creating tables and other database objects, we need a database to be created first. This is the container that we need to have at first. Let us develop a simple database for library. As we said above, first thing we need to do is to create library database. This is a single container where we can have multiple users, and their DB objects.

Let us create a library database as below.

CREATE DATABASE library;

P.S: – One should have admin privilege to create a DB and see what all DBs are created. In addition, a DB cannot be created inside another DB.

Above query simply creates a library database with all its parameter values set to default. It will have multiple parameter files to be set up while creating a DB. These files correspond to initialization parameter, configuration files, tablespace details etc. these files will take default values if they are not specified while creating a DB. When DB is created it will have number of default users and they will be locked at the beginning. If we need to login to DB and need to use / create objects inside them, then we need to unlock these users. This can be done while creating DB itself or latter by altering the user. The two main default users of DB is SYS and SYSTEM. Its password can be changed while creating DB as follows:

CREATE DATABASE library
USER SYS IDENTIFIED BY sys_pwd
USER SYSTEM IDENTIFIED BY system_pwd;

This will change their default password to the passwords mentioned above. We can even change passwords of other users while creating DB in the same way.

Other list of parameter files, their locations, size etc can also be changed while creating DB. But to keep it simple and understandable, lets make it as default.  Details about those files and settings are shown at the end of the article which creates ORACLE database.

Translate »