SQL क्या होता है | SQL कितने प्रकार के होते है | SQL Command

 

 

SQL :- SQL, in full structured query language, computer language designed for eliciting information from databases


TYPES OF SQL COMMONDS:-

1.     DDL in SQL

DDL (Data Difination language)allows you to create SQL statements to make operations with database data structures (schemas, tables etc.).


 

 CREATE

CREATE statement is used to create a new database, table, index or stored procedure.

syntex:-                          CREATE DATABASE;

                                                          CRAETE TABLE table_name;

Create database example:                               CREATE DATABASE gpgjaunpur;

Create table example:                                       

CREATE TABLE student (id INT,name VARCHAR(255));

 




DROP    DROP statement allows you to remove database, table, index or stored procedure.

 

syntex:-                  DROP DATABASE database_name;

                                              DROP TABLE table_name;

 

Drop database example:                      DROP DATABASE gpgjaunpur;

 

Drop table example:                            DROP TABLE student;

ALTER

ALTER is used to modify existing database data structures (database, table).

syntex:-                  ALTER TABLE table_name ADD colom-name datatype;

Alter table example:   ALTER TABLE student ADD last_name VARCHAR(20);

 


 TRUNCATE

TRUNCATE operation is used to delete all table records. Logically it’s the same as DELETE command.

Differences between DELETE and TRUNCATE commands are:

  • TRUNCATE  is really faster
  • TRUNCATE cannot be rolled back
  • TRUNCATE command does not invoke ON DELETE triggers

syntex:-  TRUNCATE table_name;

Example:         TRUNCATE student;

 

What is Database and its Feachars (डेटाबेस क्या है और इसके फीचर्स)

2.   DML in SQL:-

DML is a Data Manipulation Language, it’s used to build SQL queries to manipulate (select, insert, update, delete etc.) data in the database.

 INSERT

INSERT command is used to add new rows into the database table.

syntex:-  INSERT INTO table_name(colom_name1,colom_name2)values(‘data1’,’data2’);

Example:         INSERT INTO student (name, lastname) VALUES ('TIPUS', 'SULTAN');

  


UPDATE

UPDATE statement modifies records into the table.

syntex:-  UPDATE table_name SET colum_name = ‘value1’ WHERE colom_name = 'value2'

Example:                     UPDATE student SET name = 'TIPU' WHERE last_name = 'SULTAN';

 

 DELETE

DELETE query removes entries from the table.

syntex:-  DELETE FROM table_name WHERE colom-name = 'value';

Example:         DELETE FROM student WHERE name = 'TIPU';


 

 

3.   DQL in SQL:-

            Data Query Language (DQL) is part of the base grouping of SQL sub-languages.

syntex:-  SELECT * from table_name;

            SELECT name,lastname FROM table_name;

Example:         SELECT * FROM student;

 


4.   DCL in SQL:-

DCL commands are used to grant and take back authority from any database user.

Here are some commands that come under DCL:

 a. Grant: It is used to give user access privileges to a database.

Example

GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_USER;  

  b. Revoke: It is used to take back permissions from the user.

Example

REVOKE SELECT, UPDATE ON MY_TABLE FROM USER1, USER2; 

 

 



कोई टिप्पणी नहीं

क्या आप के पास हमारे लिए कोई सुझाव है।

Blogger द्वारा संचालित.