HOW TO USE SQL?

WHY USE SQL (STRUCTURED QUERY LANGUAGE)?

While Excel can only handle data containing up to one million row, businesses today generate data in the billions and trillions.To manage such vast amounts of data, databases and indespensable.

NOW, HOW TO CREATE TABLES IN SQL?

In SQL, we utilize the CREATE command to create tables..

SYNTAX : 

CREATE TABLE   "TABLE NAME"(

"COLUMN 1"   "data type for column 1"

"COLUMN 2"  " data type for column 2" ,

"COLUMN N"   'data type for column n",

[table constraint]);

CONSTRAINTS:

1. NOT NULL : Column cannot have null values 

2. DEFAULT : Provides a default value.

3. UNIQUE : All values in column are different.

4. CHECK : Makes sure that all values.

5. PRIMARY KEY : It is use to uniquely identify a row in the table.

6.FOREIGN KEY : It is use to ensure referential integreting of data.

INSERT COMMAND

The INSERT INTO statement is used to add new records into a database table.

SYNTAX:

--- Single row (without column names specified)

INSERT INTO "table _name"( "column 1", "column 2",....)

VALUES ("value 1", " value 2",....);

----Single row ( with column names specified) 

 INSERT INTO customer_table ( cust_id , first_name , age , email_id )

VALUES (2, 'dee', '22', d@xyz.com);

----Mutiple row 

INSERT INTO customer_table 

VALUES (1,'ee', 'ef' , '35', 'ef@xyz.com),

  (1, 'gee', 'eh', '42', 'gh@xyz.com)

  (1, 'eye' , 'jay', '62' , 'ig@xyz.com);

Comments

Popular posts from this blog

PYTHON - OOP(OBJECT ORIENTED PROGRAMMING) - PART 1

How to create Macros in Excel