SQL vs PL SQL
SQL (Structured Query Language) yog tus qauv lus los sau cov ntaub ntawv nkag nkag. SQL yog cov lus yooj yim, uas tso cai rau khaws, ntxig, tshem tawm, hloov kho cov ntaub ntawv raws li tus neeg siv xav tau. Tsuas yog nws yog cov ntaub ntawv qhia lus rau kev xaiv thiab tswj cov ntaub ntawv. PL SQL (Procedural Language/Structured Query Language) yog ib tug txheej txheem extension lus rau cov ntaub ntawv nkag thiab tswj los ntawm Oracle.
“PL/SQL, Oracle cov txheej txheem txuas ntxiv ntawm SQL, yog qib thib plaub-tiam programming lus (4GL). Nws muaj cov yam ntxwv niaj hnub xws li cov ntaub ntawv encapsulation, overloading, sau hom, tshwj xeeb tuav, thiab cov ntaub ntawv zais. PL / SQL kuj tseem muaj kev nkag tau yooj yim SQL, kev sib koom ua ke nruj nrog Oracle server thiab cov cuab yeej, kev txav mus los, thiab kev nyab xeeb."
SQL
Structured query language (SQL) pronounced as "sequel" is a database computer language language tsim los tswj cov ntaub ntawv nyob rau hauv relational database tswj systems (RDBMS), thiab Ameslikas raws li relational algebra.
Cov peev txheej ntawm SQL yog txhawm rau ntxig cov ntaub ntawv thiab ua cov hloov tshiab, rho tawm, tsim qauv, hloov kho schema thiab cov ntaub ntawv nkag mus tswj cov ntaub ntawv.
SQL muaj cov ntsiab lus, faib rau hauv cov hauv qab no:
Cov Lus Nug - Rov qab cov ntaub ntawv, raws li cov txheej txheem tshwj xeeb. Muaj ob peb lo lus tseem ceeb uas tuaj yeem siv rau hauv cov lus nug. (Xaiv, Los Ntawm, Qhov twg, Muaj, Pab Pawg los ntawm thiab xaj los ntawm)
e.g: SELECTFROM table1 NTAWM KAM1 > condition ORDER BY column2;
nqe lus - Qhov ntawd tuaj yeem tswj kev lag luam, kev khiav haujlwm, kev sib txuas, kev sib tham, lossis kev kuaj mob
Kev nthuav qhia - Qhov ntawd tuaj yeem tsim tau;
Scalar values
Cov kab uas muaj kab thiab kab ntawm cov ntaub ntawv
Predicates -Specify tej yam kev mob uas yuav raug soj ntsuam rau SQL Boolean (tseeb/false/unknown)
Clauses - Cov ntsiab lus tseem ceeb ntawm cov lus thiab cov lus nug
PL/SQL
PL / SQL (Cov Txheej Txheem Lus / Cov Lus Nug Cov Lus Nug) yog Oracle Corporation cov txheej txheem txuas ntxiv rau SQL thiab Oracle cov ntaub ntawv sib txheeb. PL/SQL txhawb kev sib txawv, cov xwm txheej, voj voog, arrays, kev zam. PL/SQL qhov tseem ceeb ntawm cov thawv ntim khoom tuaj yeem ua raws li cov ntaub ntawv oracle. Cov neeg tsim tawm software tuaj yeem cog PL / SQL chav ua haujlwm rau hauv cov ntaub ntawv ncaj.
PL / SQL program units tuaj yeem txhais raws li hauv qab no:
Anonymous blocks
Forms lub hauv paus ntawm qhov yooj yim PL / SQL code
Functions
Functions yog ib phau ntawm SQL thiab PL/SQL nqe lus. Cov haujlwm ua haujlwm ua haujlwm thiab yuav tsum rov qab tus nqi rau ib puag ncig hu.
txheej txheem
Cov txheej txheem zoo ib yam li Cov Haujlwm. Cov txheej txheem kuj tuaj yeem ua tiav los ua haujlwm. Cov txheej txheem tsis tuaj yeem siv hauv SQL nqe lus, tuaj yeem rov qab tau ntau yam txiaj ntsig. Ntxiv rau, cov haujlwm tuaj yeem raug hu los ntawm SQL, thaum cov txheej txheem tsis tuaj yeem.
Packages
Kev siv pob khoom yog rov siv cov lej. Cov pob khoom yog pab pawg ntawm kev sib txuas ua haujlwm, Cov txheej txheem, sib txawv, PL / SQL lub rooj thiab sau HOM nqe lus, Constants & Cursors thiab lwm yam… Cov pob khoom feem ntau muaj ob ntu, qhov tshwj xeeb thiab lub cev
Ob qhov zoo ntawm pob khoom suav nrog:
Modular mus kom ze, encapsulation ntawm kev lag luam logic
Siv tej pob khoom sib txawv tuaj yeem tshaj tawm hauv qib kev sib tham
Hom kev hloov pauv hauv PL / SQL
Variables
Nummeric variables
tus yam ntxwv hloov pauv
Hnub hloov pauv
Cov ntaub ntawv rau cov kab tshwj xeeb
Qhov txawv ntawm SQL thiab PL / SQL
SQL yog cov ntaub ntawv qhia lus rau xaiv thiab tswj cov ntaub ntawv tab sis PL SQL yog cov lus txheej txheem los tsim cov ntawv thov.
SQL ua ib nqe lus ntawm ib lub sijhawm whereas hauv PL SQL thaiv cov lej tuaj yeem raug tua.
SQL yog tshaj tawm qhov twg raws li PL SQL yog txheej txheem.
SQL yog siv los sau Cov Lus Nug, Cov Lus Qhia Cov Lus (DML) thiab Cov Lus Txhais Lus (DDL) whereas PL SQL yog siv los sau Program blocks, Triggers, Functions, Procedures, and Packages.
Recap:
SQL yog cov lus nug cov lus nug. Hauv SQL ntau cov lus nug yog siv los lis cov ntaub ntawv hauv ib qho yooj yim. PL/SQL yog cov lus txheej txheem muaj ntau hom kev sib txawv, kev ua haujlwm thiab cov txheej txheem. SQL tso cai rau tus tsim tawm ib qho lus nug lossis ua tiav ib qho ntxig / hloov tshiab / rho tawm ntawm ib lub sijhawm, thaum PL / SQL tso cai sau ntawv ua tiav cov haujlwm kom ua tiav ntau yam xaiv / ntxig / hloov kho / tshem tawm ib zaug. SQL yog cov ntaub ntawv yooj yim taw qhia lus thaum PL / SQL programming lus.