SQL: Structure Query Language

Parts of SQL: 

DDL:-data definition language, work with column (create, alter, drop)

     It is permanent in nature it doesn't roll back.

DML:-data manipulation language work with row (insert, update, delete)

     It is not in permanent need to commit or save.

DCL:-data control language (grant, revoke)

TCL:-transaction control language (commit, rollback)

DRL:-data retrieve language (select)

 

Database

There are two type of data base

 

 System Database: - By default when install

·       Master

·       Model

·       MS dB

·       Temp DB

These are some data base that is inside the system database and provided by

SQL server installation and these are required for proper functioning of SQL server

 

 User Defined Database:- Create by user, when user creates data base, two file generates

·       .mdf file:- Data File(contain actual data

·       .ldf file:- Transaction Log File(contain transaction data

How to change the name of data base

 

·       1. Alter database data base name modify name=new name

·       2. We can use system store procedure sp_renameDB 'olddatabasename', 'Newdatabasename'.

Drop data base

 

If we drop the database then it delete mdf and ldf file.

We can’t delete database if it is in currently use. So if other are connected we need to put in single user mode

***Alter database data base name set single user with rollback immediate.

Roll back immediate will rollback all immediate transaction and close connection to the database.

 

Note: - system database can't be dropped.

Table 

Create table table_name (columns data type)

Add column:-

Alter table table_name add new_column_name.

Delete column

Alter table table_name drop column column_name