0 ratings 0% found this document useful (0 votes) 478 views 7 pages Basic of SQL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Carousel Previous Carousel Next
Save Basic of SQL For Later ‘BASIC SQL
@ What fs S@L?
V SOL stands fox Structured Query Language -
It is used for string and managing aata in
velational database management System (RDBMS)
@ SQL Commands:
@ SELECT - Extract data from database.
VY The dara veturned is stored in 4 vesult
favie , called the vwesult - Set.
Licoma@e ( LINKEDIN).
WOTES GALLERY (TELEGRAM).
SELECT _ Syntax
SELECT Colummn1, Column2.....
From +table- name,
Heve , Column 1, Column2,.... ave the Fleid
names of the table you want to select dara
From.
IF you want +0 GCODING BUGS DNOTES GALLERY
TUL KomAR LunikeDin). INSTAGHAGRAWodeatdbatul
4SELECT columns Example
ae Following SaL statement Selects tne
“customer Name", “ City" , and “Country " columns
‘ INSTAGRAM satul
from the “Customers” table : SCODING BUGS“ NOTES GALLERY
Example
NOTES GALLERY CreceaRam 1
e UPDATE
Updates data jn _a database.
Whe UPDATE Statement is used 10 modify the
existing weeords jn a table.
UPDATE Syntax !
UPDATE table name
SET Columni = valuet,
column 2 = value 2,....
WHERE Condition;
UPDATE Customer
SET Contact nlame = ‘Kanth’
clty = Fyank Purt
ATUL KUMAR LINKEDIN).Deletes datq fyom a database.
Te DELETE starement {ts used to delete existing
vecords In a table.
Devete Syntax,
DELETE FROM table name
WHERE Condition ;
DeveTe FROM Customers
wyEere Customer r ‘
name = ‘Kanth ;
@ INSERT INTO
Sexvts new data fo
The INSERT INTO statement js used to tnsert new
vecords In Q table.
INSERT JNITO Syntax
Tr is possible to write the ENSERT INTO srarement
in two woys t
© Specify the poth the column names and the values
yO be insexted:
INSERT INTO table _ name
Ceolumnt, Column2 , Column
values (valuel, vqlue2, value 3,
unt (Lin KEDIAL) +INSERT INTO table — name
values (vatuel, value2 , value3,....)3
Example
INSERT INTO Customers ( customer Name
contact Name, Advess, city ,
Postal code, country )
values (‘Kanth', ‘Tom B:, ‘skagen 21’,
‘stavangey', '4ooe', ' Noyway’) ;
NOTES GALLERY (TELEGRAM),
@ CREATE DATABASE
Cweates a new Database.
The _Create Daragace Statement igs used to create
@ new SQL Database.
Syntox
fereate DATABASE database name;
Example
CREATE DATABASE text DB;
© ALTER TABLE,
Modifies a table
The ALTER TABLE Statement is used to add, delete, or
modify columns in an existing table. And also
used to add S dyop various constvaints on
existing table.
Continue —>R LE _— ADD column.
ALTERTABLE table_ name
APBD Column— name data
ALTER TABLE Customer
ADD Email Vaychar (255 )
_DRoP column
ALTER TABLE table-nQme
DRor Column Column_ name ;
Example
eee Customers
DROP COLUMN Email 5
NOTES GALLERY (TELEGRAM),
Creates Q@ new table.
The CREATE TABLE statement is used to create q
neW table in a datanase.
_Syntax
CREATE TABLE table_name (
Columni datatype »
column 2 datatype ,
coimn 3 datatype »
seCREATE TABLE Person (
Person ID int
Lastname Vaychay (265 ),
_Fivst lame varchar (2ss ),
Addyess Varchar (255 ),
City Vaychay (255 )
3
ATUL Kumme (LINKEDIN) »
NOTES GALLERY (TELEGRAM),
Deletes @ table.
The _DeOP TABLE gtatement ts used to dyop an
existing table in a data base.
Syntax
DROP TABLE table. ngmes
Example
DROP TABLE ShipPers 5
@ CREATE INDE.
Creates an Index ( Search key )
Whe CREATE INDEX Cratement is Used to Create
Indexes In table.
Indexes ave used to vetyive data From the data base
More quickly than Otherwise-
The users Cannot see the Indexes, they aye jest
used to Speed up searches / queries.
Continue ——>CREATE INDEX Index name
ON table. name
,column2,
CREATE INDEX idx lastname
ON Percon( Lastalame , First Name) ;
e oP a: GALLERY (TELEGRAM),
_Deetes on Index
e_DeoP INDEX statement fs used to delete an
index in @ table.
ALTER TABLE table _ name
DROP INDEX index Name 5