CREATE/DROP DATABASE/TABLES




In this Post , We will be studying creating databases and tables.
Please note that we will be using SQL Server for all queries in these tutorials.



  • CREATE DATABASE.- Used to create database in Database Server.


Syntax


CREATE DATABASE
 database_name



Example -

CREATE DATABASE Test


Output


command(s) completed successfully




  • CREATE TABLE-Used to create table in database


Syntax

CREATE TABLE table_name
(Column_name_1,datatype(size),column_name_2 datatype(size))



Example -


CREATE TABLE details(Id int , name varchar(20), phone varchar(10))


Output


command(s) completed successfully



Note - you don't need to put semicolon after statement in SQL server.



Now we learned how to create Database and Tables , Let's learn how to Drop/Delete Database and Tables.
Please note that we are using SQL server for all queries in these tutorials



  • DELETE DATABASE.


Syntax

DROP DATABASE
database_name


Example


DROP DATABASE Test


Output

command(s) completed successfully.

Database will be deleted from Server.




  • Delete Table

Syntax

DROP TABLE
table_name



Example

DROP TABLE Detail



Output

command(s) completed successfully.
CREATE/DROP DATABASE/TABLES CREATE/DROP DATABASE/TABLES Reviewed by vishal on August 03, 2017 Rating: 5

No comments