SQL class notes
SQL class notes
/*
Multiple Comment
SQL Language is very easy to learn.
SQL Language is not case sensitive
*/
-------------------------------
Create 5 Tables
Student_info
Employee_info
Customer_info
Sales_Info
Product_Info
Create 5 Tables
Student_info
Employee_info
Customer_info
Sales_Info
Product_Info
--- Identifier Rules
/*
--Data Types
NUMERIC
SMALLINT
INT
BIGINT
DECIMAL
FLOAT
MONEY
CHARACTER
CHAR
VARCHAR
NCHAR
NVARCHAR
TEXT
DATE
DATE
TIME
DATETIME
DATETIME2
*/
-----------------------------------------------------------------
-----------DELETE
----------- How to insert the data from one table to another table.
---------------------------------------------
---------------------------------
SELECT 100+450
------------ALTER STATEMENT
-- ADD Column
SELECT * FROM employee_info_20250118
-- Drop Column
--------------------
-------
--- 50K
-------
/*
--Development Life Cycle Environments
1.Dev --
2.QA/ TESTING
3.UAT (User Acceptance Testing)
4.PRODUCTION
*/
------------------------------------- TRUNCATE
TRUCATE
1.We can't delete specific records
2.TRUNCATE statement will remove all the records at one go.
3.It will faster than DELETE
DROP
1. DROP statment will remove entire table from database itself.
*/
-------------------------COMMIT/ROLLBACK/SAVEPOINT
---ROLLBACK: It undo the changes of any given statement including TRUCNATE/DROP .
-- to rollback the transaction we must to BEGIN THE transation using BEGIN
TRANSACTION clause
--COMMIT-- Save the data permernatly in the database which we cant rollback.
SELECT * FROM [dbo].[customer_info_bkp_20250218]
BEGIN TRANSACTION
ROLLBACK
-----------------------------------
BEGIN TRANSACTION
ROLLBACK
---------------------
BEGIN TRANSACTION
ROLLBACK
SELECT * FROM [customer_info_bkp_20250219]
----------------------------------------------
BEGIN TRANSACTION
commit
rollback
-------------------------------------
Source System
20Lac
Tomorrow 10 am to 2.00 pm