HOW TO CREATE A DATABASE IN SQL

CREATE DATABASE

To create a database in SQL the CREATE DATABASE statement is used. The database name should be unique and less than 128 characters.

To create a database in SQL and SQL Server use the command-

CREATE DATABASE database_name;

Example-

CREATE DATABASE student_db;

To view database in SQL use command-

SHOW DATABASE;

To Create or Replace existing database in SQL use command-

CREATE OR REPLACE DATABASE database_name ;

To list all databases stored in the SQL Server database engine use T-SQL command-

SELECT name FROM master.sys.databases ORDER BY name;

We can also use stored procedure “sp_databases” in SQL server to view the list of all databases, including its size and remarks if any by executing the command-

EXEC sp_databases;


Leave a Reply

Your email address will not be published. Required fields are marked *