0 ratings0% found this document useful (0 votes) 64 views5 pagesSQL For Beginners
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
[Basic SAL for Begunwers
what i¢ SQL? @ rect Kanth
SQL Stands for Shuckwred gong Language
DE ig used for Storing and manogind “data in xcl-
ational data, base management Sxyctem (2DBM=),
SAL commands .
© Sevect- Fatvach data tom Serect Columms £xample
dactabate. The following SAL Statemenb
The data velarned is gtoved| Selects the “customer WN ,
- a seals TMs catted “aty ", ard " couritiy "columns
Mesut -Dets from the “Customers” table:
SELect Syntax Example
SELECT column, columnp,.-] [Sevett Customer Name, City ,
FRom tabte_name, Country FRM customers 5
Here, column ,tolumn2,..... @UPDATE- updates dala
a the fied names oe a database.
ble you want to Seleck the uppare statement is
data “from. Df you wart — used to modify “the existing
to Select atl the’ felds ami- yecords in a table.
lable in the table, ux the Uppy
following Syntant: eevee Syoiy :
Select ' Prom table. nome@ INSERT INTO- inserts
Example new data into a databa.
UPDATE Customer }
in a table.
@ Detete- delela data = INSERT TNTO Syntar
from a databate. a i ean is poscible to wiile the
The DELETE Statement ig TASeeT INTO Statemunt in feo
wed to delete enisting WOys:
records int) a table % heii bath the column
2 nama and the value to be
DELETE Syntoe | inserted:
DELETE FROM table_name INSEET INTO table nome
WHERE condition ¢ Ccolumny, column2, colunma,.....)
Vanue .
Example UES (valuel, values, valurs,...)
DELETE FROM customer
WHERE Customer
name = “kant;
INseeT INT table_name |
\VALves (value, Valuer, values, )3
< ssK
Wlow- bepec. inExomple @AlttTer tase = -
——___ | Modifies a table
InseeT Into customers
Ceustomey Name, contact Name,
Address, city , postal code,
Te ued to add, del, o
County’) | | Modify column in an evating
Varves (“anth’, ‘Tom B., | Fable. And alo used to add
| Sdrop vavious conshaints on
ahem “HOS eiliding table,
e ALTER TABLE - ADD Column
Te DATABAS
CREATE DATieese~ ALTER TABLE table _ name
Creates a Qa New “ee base.
. Ee ADD colurmn_name datertippe ;
statement’ ts uted to onal Example
@ New Gar Database. ALTER Taaie cultomou
Syntax i“ Email yaychet (255);
CREATE DATABASE
ALTER Ta TABLE table name
Exomple DRoP Column Column name,
[create paTaBese tet DB] — Fxomple
WER TABLE customers
DROP coLuMN Emails
[aa
3
7© Create TABLE -
Creates a new table.
The ¢ 26 e
@ DeoP. TABLE- Deletes,
a 1 table.
i8 uted to create a noo i he to
table ina databaue.
Syntow
p an envsting
table in a data bue.
Syntax
| CReate TABLE table name (| Dep TABLE table vame;
Column data tape,
Columne data type,
Cotumn3 data tape,
de
Exom ple
ae
CREATE TABLE Porson (
Person£D int,
hast Nome Vavchas (255),
Fivst Nome verchos (295)
Addvess vatchas (5), 9
city varchar Co55)
>
| Example
@ cReme Pndex- creates
an Tn. Cech ht)
is wed D orate Lrdenes
in table.
Indeves ave wed to vetview
data fom “tw data boleThe wow cannot see @ DROP TNDEx -
the indews » they are jut
wed to “fe up ime
gpusnies
deletes an Tndexw
ROP Index Statement
‘ a to ddele an mdot
ina table,
dntos,
CREATE INDEY Inden_nome}
ON toble name Alte? TABLE table_ name
(column, column’,-)} PROP INDEX i ndex_Names
Frample
CREATE TuDE~ idx tostro
ON Person (east Nome First
Name);
{ seme x
www. bepec.in