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
You are on page 1/ 7
BASIC SQL
@ What fs SaL?
Vv SGL stands fox Structuved Query Language
It is used for sting and managing dara in
velationa] database management system (RDBMS)
@ S@L Commands:
@ SELECT - Extract data from database.
V The dara veturned is stored in @ vesult
table , called the yesult - set.
SELECT Syntax ‘NOTES GALLERY (TELEGRAM),
+f SELECT Colurmnt, Column 2,....
From +table- name,
Here , column 1, Column2,.... Ave the Field
names of the table you want to select dara
From.
IF you want to select all the fields
auailable §n the table use the
Foilowing SYNTax +
SELECT* From +table— nameSELECT columns example
A: Following Sar statement Selects tne
"customer Name", “ “city” j
and “country” "columns
from the “Customers” table :
Example
Abres GALL
TE
Updates data jn_a database.
Pp
The UPDATE Statement fs used 10 modify the
existing yeeords jn a table
ERY CreceaRamy
UPDATE Syntax ‘
UPDATE table name
SET Column 1
column 2
WHERE Condition ;
value 1,
value 2,..
UPDATE Customers
t
SET Conrack nlame = Kanth’
Clty =Fyank Furte DeLcTE.
Deletes datq fyvom 4 database.
The DELETE sturement js used to delete existing
vecords In a table.
De LETE Sy ntox
DELETE FROM table_ name
WHERE Condition 5
DELETE FROM Customers
WHERE Customer i ;
name = Kanth ;
@ INSERT INTO
Servts new data domgbase.
The INSERT INTO statement js used to tnsext new
yewrds In a table.
NSERT_JNTO Syntax
Tr is possible qo write the [NSERT INTO starement
in twWo woys:
O Specify the pth the column names and tne values
tO be fnsested:
INSERT INTO table _ name
Ccolumnt, Column2 , Column
vajues (valuel, value2, value 3,—
Insert INTO table— name
values Cvatuel, value 2 , value 3,...)3
®
Example
INSERT INTO Customers ( customer Nam
Contact Name, Advess, city ,
Postal code, country )
vatues (‘kanth', ‘Tom B., ‘skagen 21’,
‘stavangex', '&oo06', ‘Noyway’) ;
ATUL Kum FR (LINKEDIN.
NOTES GALLERY (TELEGRAM)
e ATE ASE.
Creates a new Database.
The _Create DArAgase Statement ws used to create
@ new SOL Database.
Syntox
ICREATE DATABASE database name;
Example
CREATE DATABASE text DBs
@ ALTER TABLE.
Modifies a table
The ALTER TABLE Statement is used to add, delete, or
modify columns In an existing table. And also
used (0 add 2 dyop vawious constraints on
existing table.
Continue —>ALTER TABLE — ADD column.
ALTERTABLE ta4ble_ name
ABD Column— name data pe
Example
ALTER TABLE Customer
ADD Email Vaycenar (255 _)
_DRoP column
ALTER TABLE table-ndme
DRoP column Colwmn_ name 5
Example
ALTER TABLE Customers
DROPCOLUMN Email ;
ATUL
A AR (Linikedial) .
NOTES GALLERY (TELEGRAM)
@ CREATE TABLE
Creates a new table.
The CREATE TABLE starement fs Used tO Create q
new table in a datanasce.
Syntax
CREATE TABLE table_name (
Columni datatype »
column 2 datatype ,
cowmn 3 datatyre »> example
CREATE TABLE Person (
Person ID int
Lact Name vaychay (266 ),
Fiyst nlame varchar (ass ),
Addyess Varchay (255 ),
Cry varchar (255 )
a
ATUL Kumar (Linkedin) -
NOTES GALLERY (TELEGRAM),
@ DROP TABLE
Deletes @ table.
The DROP TABLE statement is used to dyop an
existing table in a data base.
Syntax
DROP TABLE table_ names
Example
DROP TABLE SnipPers 5
e EATE INDE,
Cweates an Index ( Seavch key )
‘The CREATE INDEX ¢rarement is Used to Create
Indexes |n table.
Indexes axe used 40 vetyive data from the data base
More qwickly than Otherwise.
The uUsevs Cannot see the Indexes, they ave just
used to Speed up searches / queries.
Continue —>
ATUL KOMAR CLINKEDUL).CREATE INDEX Index name
ON table. name
¢ column 1, column2,
CREATE INDEX idx lastname
ON Percon( Lasralame , Ss ee
ST ciALLeRy (TELEGRAM).
0 pee et Se
_Deretes on Index
“e_DeoP INDEX statement fs used to delete an
index jn q table.
ALTER TABLE table name
DROP INDEX Index Name 5