Isifundo seMySQL: Isikhokelo sabaQalayo sokuFunda i-MySQL

Ibhlog

Isifundo seMySQL: Isikhokelo sabaQalayo sokuFunda i-MySQL

Isifundo se-MySQL: Isikhokelo sabaQalayo sokuFunda i-MySQL-Makhe sijonge kwisifundo se-MySQL esinzulu esivavanya yonke imisebenzi kunye nemiyalelo ekufuneka uyivavanye kwindawo yokugcina ulwazi ...



Isifundo se-MySQL linqaku lesibini kolu ngcelele lwebhlog. Kwinqaku elandulela eli, Yintoni i-MySQL , Ndikwazise kuwo onke amagama asisiseko ofuna ukuwaqonda ngaphambi kokuba uqalise ngale database yolwalamano. Kule bhlog ye-MySQL, uya kuba ufunda yonke imisebenzi kunye nemiyalelo oyifunayo ukuphonononga ugcino lwedatha yakho.

Izihloko ekuthethwa ngazo kweli nqaku zahlulwe zangamacandelo ama-4: i-DDL, i-DML, i-DC, kunye ne-TCL.



  • Inkqubo ye- I-DDL (ULwimi lokuLawulwa koLwazi) luqukethe loo miyalelo esetyenziselwa ukuchaza isiseko sedatha. Umzekelo: YENZA, YIHLAWULA, NGOKUPHELELEYO, YOKUQHUBA, YOKUPHAWULA, YENZA IGAMA.
  • Inkqubo ye- I-DML (ULwimi lokuLawulwa koLwazi) imiyalelo yokujongana nokuphathwa kwedatha ekhoyo kwiziko ledatha. Umzekelo: KHETHA, FAKA, HLAZIYA, SUSA.
  • Inkqubo ye- I-DCL (ULawulo loLwimi uLwimi) imiyalelo ijongene namalungelo, iimvume kunye nolunye ulawulo lwenkqubo yedatha. Umzekelo: YONIKEZELA, VULA
  • Inkqubo ye- TCL (ULwimi lokuThengiswa koLwimi) luqukethe loo miyalelo ejongene ikakhulu nokuthengiselana kwesiseko sedatha.

Ngaphandle kwemiyalelo, ezi zilandelayo zezi zihloko zixutywe kwibhlog:

  • Iindidi ezahlukeneyo zezitshixo kwindawo yogcino lwedatha
  • Imiqobo esetyenzisiweyo kwindawo yogcino lwedatha
  • Imibuzo edibeneyo
  • Joyina
  • Cwangcisa ukusebenza

Siza kugubungela nganye yezi ndidi nganye nganye.



Kule bhlog kwiMySQL Tutorial, ndiza kuqwalasela indawo engezantsi njengomzekelo, ukubonisa indlela yokubhala imiyalelo.

Ke, masiqale ngoku!

Isifundo se-MySQL: Inkcazo yedatha (DDL) Imiyalelo

Eli candelo liqulathe loo miyalelo, onokuchaza ngayo indawo yakho egciniweyo. Imiyalelo yile:

  • DALA
  • UBUDALA
  • I-DROP
  • UQINISEKISO
  • Qamba IGAMA

Ngoku, ngaphambi kokuba ndiqale ngemiyalelo, mandikuxelele indlela yokukhankanya amagqabantshintshi kwi-MySQL.

Izimvo

Njengalo naluphi na olunye ulwimi lwenkqubo, kukho iindidi ezimbini zezimvo.

  • ** Amagqabantshintshi omgca omnye: ** Amagqabantshintshi omgca omnye aqala ngo-'- '. Ke, nawuphi na umbhalo okhankanyiweyo emva-kude kube sekupheleni komgca awuzukuhoywa ngumhlanganisi.

Umzekelo:

--Select all: SELECT * FROM Students;
  • Amagqabantshintshi emiNinzi: * Izimvo zemigca emininzi ziqala ngo / kwaye uphele ngo /. Ke, nawuphi na umbhalo okhankanyiweyo phakathi / kwaye * / iya kuhoywa ngumqokeleli.

Umzekelo:

/*Select all the columns of all the records in the Students table:*/ SELECT * FROM Students;

Ngoku, ukuba uyazi ukuba ungazichaza njani izimvo kwi-MySQL, masiqhubeke nemiyalelo ye-DDL.

DALA

Isiteyitimenti sokuyila sisetyenziselwa ukwenza ischema, iitafile okanye isalathiso.

Ingxelo 'YENZA ISHEMA'

Le ngxelo isetyenziselwa ukwenza isiseko sedatha.

Isintakisi:

CREATE SCHEMA Database_Name;

Umzekelo:

CREATE SCHEMA StudentsInfo;

Ingxelo 'YENZA ISICWANGCISO'

Le ngxelo isetyenziselwa ukwenza itafile entsha kwiziko ledatha.

Isintakisi:
CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype, .... );
Umzekelo:
CREATE TABLE Students ( StudentID int, StudentName varchar(255), ParentName varchar(255), Address varchar(255), PostalCode int, City varchar(255) );

Ingxelo 'YENZA ITHEYIBHILE AS'

Le ngxelo isetyenziselwa ukwenza itafile entsha kwitafile esele ikho. Ke, le tafile ifumana iinkcazo ezifanayo zekholamu.

Isintakisi:

CREATE TABLE SELECT FROM new_table_name AScolumn1, column2,...existing_table_name WHERE ....;

Umzekelo:

CREATE TABLE ExampleTable AS SELECT Studentname, Parentname FROM Students;

UBUDALA

ALTER umyalelo usetyenziselwa ukongeza, ukuguqula okanye ukucima iingxaki okanye iikholamu.

INgxelo ye 'ALTER TABLE'

Le ngxelo isetyenziselwa ukongeza, ukulungisa okanye ukucima iingxaki kunye neekholamu kwitafile.

Isintakisi:

ALTER TABLE table_name ADD column_name datatype;

Umzekelo:

ALTER TABLE Students ADD DateOfBirth date;

I-DROP

Umyalelo we-DROP usetyenziselwa ukucima i-database, iitafile, okanye iikholamu.

Ingxelo ye 'DROP SCHEMA'

Le ngxelo isetyenziselwa ukulahla ischema epheleleyo.

Isintakisi:

DROP SCHEMA schema_name;

Umzekelo:

DROP SCHEMA StudentsInfo;

Ingxelo ye 'DROP TABLE'

Le nkcazo isetyenziselwa ukulahla itafile yonke kunye namaxabiso ayo.

Isintakisi:

DROP TABLE table_name;

Umzekelo:

DROP TABLE table_name;

UQINISEKISO

Le ngxelo isetyenziselwa ukucima idatha ekhoyo ngaphakathi kwetafile, kodwa itafile ayicimi.

Isintakisi:

TRUNCATE TABLE table_name;

Umzekelo:

TRUNCATE TABLE Students;

Qamba IGAMA

Le ngxelo isetyenziselwa ukuqamba enye okanye ngaphezulu kwetafile.

Isintakisi:

RENAME TABLE tbl_name TO new_tbl_name [, tbl_name2 TO new_tbl_name2] ...

Umzekelo:

RENAME Students TO Infostudents;

Ngoku, ngaphambi kokuba ndiye kumacandelo aqhubekekayo, mandikuxelele iintlobo ezahlukeneyo zamaqhosha kunye nezithintelo ekufuneka uzikhankanyile ngelixa uqhuba indawo yolwazi.

Iindidi ezahlukeneyo zezitshixo kwindawo yogcino lwedatha

Zintandathu iindidi zezitshixo, ezinokukhankanywa kwindawo yogcino lwedatha.

  • ** Isitshixo soMgqatswa: ** Iseti encinci yeempawu ezinokuthi zichonge ngokukodwa isiXhobo saziwa njengesitshixo somgqatswa. Ubudlelwane bunokubamba ngaphezulu kwesitshixo esinye somgqatswa, apho isitshixo sisitshixo esilula okanye esidityanisiweyo.
  • ** Isitshixo esiphambili: ** Iseti yeempawu ezinokuthi zichonge ngokukodwa isiQithana saziwa njengeSitshixo esiPhambili. Ke, isitshixo somgqatswa yi-superkey, kodwa ngokuchaseneyo akuyonyani.
  • Isitshixo sokuqala: Iseti yeempawu ezinokusetyenziselwa ukuchonga ngokukodwa isiQinisi esinye isitshixo esiphambili. Ke, ukuba kukho amaqhosha omgqatswa angama-3-4 akhoyo kubudlelwane, ke ezo zinokukhethwa njengesitshixo esiphambili.
  • Esinye isitshixo: Isitshixo somgqatswa ngaphandle kwesitshixo esiphambili sibizwa njengesinye isitshixo .
  • ** Isitshixo sangaphandle: ** uphawu olunokuthatha kuphela amaxabiso akhoyo njengexabiso lolunye uphawu, sisitshixo sangaphandle kwimpawu ekubhekiswa kuyo.

Imiqobo esetyenzisiweyo kwindawo yogcino lwedatha

Jonga umfanekiso ongezantsi zizithintelo ezisetyenziswe kwindawo yogcino lwedatha.

php ukukhangela uluhlu oluninzi lwesitshixo

Umzobo 1: * Imiqobo esetyenzisiweyo kwindawo yogcino lwedatha: Isifundo seMySQL *

Ngoku ukuba uyazi iintlobo ezahlukeneyo zezitshixo kunye nezithintelo, masiqhubeke siye kwicandelo elilandelayo okt Imiyalelo yokuLawulwa kweDatha.

Ulawulo lweDatha (DML) Imiyalelo

Eli candelo liqulathe loo miyalelo, onokuthi ngayo usebenzise isiseko sedatha yakho. Imiyalelo yile:

  • SEBENZISA
  • FAKA
  • UHLAZIYO
  • SUSA
  • KHETHA

Ngaphandle kwale miyalelo, kukwakho nabanye abaqhubi / imisebenzi enje:

SEBENZISA

Isiteyitimenti SOKUSETYENZISWA sisetyenziselwa ukukhankanya ukuba loluphi ugcino lwedatha ekufuneka lusetyenziselwe ukwenza yonke imisebenzi.

Isintakisi:

USE Database_name;

Umzekelo:

USE StudentsInfo;

FAKA

Le ngxelo isetyenziselwa ukufaka iirekhodi ezintsha kwitafile.

INSERT INTO statement inokubhalwa ngezi ndlela zimbini zilandelayo:

INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...); --You need not mention the column names INSERT INTO table_name VALUES (value1, value2, value3, ...);

Umzekelo:

INSERT INTO Infostudents(StudentID, StudentName, ParentName, Address, City, PostalCode, Country) VALUES ('06', 'Sanjana','Jagannath', 'Banjara Hills', 'Hyderabad', '500046', 'India'); INSERT INTO Infostudents VALUES ('07', 'Shivantini','Praveen', 'Camel Street', 'Kolkata', '700096', 'India');

UHLAZIYO

Le nkcazo isetyenziselwa ukuguqula iirekhodi ezikhoyo kwitafile.

Isintakisi:

UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;

Umzekelo:

UPDATE Infostudents SET StudentName = 'Alfred', City= 'Frankfurt' WHERE StudentID = 1;

SUSA

Le ngxelo isetyenziselwa ukucima iirekhodi ezikhoyo etafileni.

Isintakisi:

DELETE FROM table_name WHERE condition;

Umzekelo:

DELETE FROM Infostudents WHERE StudentName='Salomao';

KHETHA

Le ngxelo isetyenziselwa ukukhetha idatha kwiziko ledatha kwaye idatha ebuyisiweyo igcinwe kwitheyibhile yeziphumo, ebizwa ngokuba yi iziphumo-set .

Oku kulandelayo zindlela ezimbini zokusebenzisa le ngxelo:

Isintakisi:

SELECT column1, column2, ... FROM table_name; --(*) is used to select all from the table SELECT * FROM table_name;

Umzekelo:

SELECT StudentName, City FROM Infostudents; SELECT * FROM Infostudents;

Ngaphandle kwegama eliphambili LOKUKHETHA, siza kubona ezi ngxelo zilandelayo, ezisetyenziswa ngegama elikhethiweyo:

Ingxelo 'YOKUKHETHA UKUHLUKA'

Le nkcazo isetyenziselwa ukubuyisela kuphela amaxabiso ahlukileyo okanye ahlukileyo. Ke, ukuba unetafile enamaxabiso aphindwe kabini, ungasebenzisa le ngxelo ukudwelisa amaxabiso ahlukileyo.

Isintakisi:

SELECT DISTINCT column1, column2, ... FROM table_name;

Umzekelo:

SELECT Country FROM Students;

Ingxelo 'YOKUYALELA NGE'

Le ngxelo isetyenziselwa ukuhlela iziphumo ezinqwenelekayo ngokunyuka okanye ukwehla komyalelo. Ngokuzenzekelayo, iziphumo ziya kuhlelwa ngokonyuka komyalelo. Ukuba ufuna iirekhodi kwisiphumo esisetwe kulungelelwaniso oluhlayo, sebenzisa i IDESC igama elingundoqo.

Isintakisi:

SELECT column1, column2, ... FROM table_name ORDER BY column1, column2, ... ASC|DESC;

Umzekelo:

SELECT * FROM Infostudents ORDER BY Country; SELECT * FROM Infostudents ORDER BY Country DESC; SELECT * FROM Infostudents ORDER BY Country, StudentName; SELECT * FROM Infostudents ORDER BY Country ASC, StudentName DESC;

Ingxelo ye 'GROUP BY'

Le ngxelo isetyenziswa ngokudibanisa imisebenzi yokubeka iziphumo kwiseti enye okanye ezingaphezulu iikholamu.

Isintakisi:

SELECT column_name(s) FROM table_name WHERE condition GROUP BY column_name(s) ORDER BY column_name(s);

Umzekelo:

SELECT COUNT(StudentID), Country FROM Infostudents GROUP BY Country ORDER BY COUNT(StudentID) DESC;

Ingxelo yegatya elithi 'HAVING'

Ukusukela KUPHI igama elingundoqo alinakusetyenziswa kunye nemisebenzi ehlanganisiweyo, igatya le-HAVING laziswa.

Isintakisi:

SELECT column_name(s) FROM table_name WHERE condition GROUP BY column_name(s) HAVING condition ORDER BY column_name(s);

Umzekelo:

SELECT COUNT(StudentID), City FROM Infostudents GROUP BY City HAVING COUNT(Fees) > 23000;

ABASEBENZI BENKQUBO

Olu seto lwabasebenzi luqukethe abaqhubi abanengqiqo abanjengo KUNYE / OKANYE / HAYI .

NOMSEBENZI

Umsebenzi we AND usetyenziselwa ukucoca iirekhodi ezixhomekeke ngaphezulu kwesinye imeko. Lo msebenzisi ubonakalisa iirekhodi, ezanelisa yonke imiqathango eyahlulwe ngu-AND, kwaye inika imveliso YINYANISO.

Isintakisi:

ELECT column1, column2, ... FROM table_name WHERE condition1 AND condition2 AND condition3 ...;

Umzekelo:

SELECT * FROM Infostudents WHERE Country='Brazil' AND City='Rio Claro';

OKANYE UMSEBENZI

Umqhubi we-OR ubonakalisa ezo rekhodi ziyanelisa nayiphi na imiqathango eyahlulwe ngu-OR kwaye inika iziphumo INYANISO.

Isintakisi:

SELECT column1, column2, ... FROM table_name WHERE condition1 OR condition2 OR condition3 ...;

Umzekelo:

SELECT * FROM Infostudents WHERE City='Toronto' OR City='Seoul';

HAYI UMSEBENZI

Lo msebenzisi ubonakalisa irekhodi xa imeko (ezo) Zingeyonyani.

Isintakisi:

Uyicwangcisa njani iprojekthi ye-python
SELECT column1, column2, ... FROM table_name WHERE NOT condition;

Umzekelo:

SELECT * FROM Infostudents WHERE NOT Country='India'; --You can also combine all the above three operators and write a query like this: SELECT * FROM Infostudents WHERE Country='India' AND (City='Bangalore' OR City='Canada');

IArithmetic, iBitwise, ukuthelekisa, kunye nabaSebenzisi beKhompawundi

Jonga umfanekiso ongezantsi.

Umzobo 2: * I-Arithmetic, iBitwise, ukuthelekisa kunye nabaSebenzi beKhompawundi- Isifundo seMySQL *

Imisebenzi ehlanganisiweyo

Eli candelo lemisebenzi libandakanya le misebenzi ilandelayo:

MIN () Umsebenzi

Lo msebenzi ubuyisela elona xabiso lincinci kwikholamu ekhethiweyo kwitafile.

Isintakisi:

SELECT MIN(column_name) FROMtable_name WHEREcondition;

Umzekelo:

SELECT MIN(StudentID) AS SmallestID FROM Infostudents;

Umsebenzi we-MAX ()

Lo msebenzi ubuyisela elona xabiso likhulu kwikholamu ekhethiweyo kwitafile.

asp.net iakhawunti yomatshini windows 7

Isintakisi:

SELECT MAX(column_name) FROM table_name WHERE condition;

Umzekelo:

SELECT MAX(Fees) AS SmallestFees FROM Infostudents;

COUNT () Umsebenzi

Lo msebenzi ubuyisela inani leerowu ezihambelana neekhrayitheriya ezichaziweyo.

Isintakisi:

SELECT COUNT(column_name) FROM table_name WHERE condition;

Umzekelo:

SELECT COUNT(StudentID) FROM Infostudents;

Umsebenzi we-AVG ()

Lo msebenzi ubuyisela ixabiso eliphakathi lekholamu oyikhethileyo.

Isintakisi:

SELECT AVG(column_name) FROM table_name WHERE condition;

Umzekelo:

SELECT AVG(Fees) FROM Infostudents;

SUM () Umsebenzi

Lo msebenzi ubuyisela inani elipheleleyo lekholamu yamanani oyikhethileyo.

Isintakisi:

SELECT SUM(column_name) FROM table_name WHERE condition;

Umzekelo:

SELECT SUM(Fees) FROM Infostudents;

ABASEBENZI ABAKHETHEKILEYO

Eli candelo libandakanya abaqhubi balandelayo:

PHAKATHI komqhubi

Lo mqhubi ngumsebenzisi obandakanyayo, okhetha amaxabiso (amanani, izicatshulwa okanye imihla) kuluhlu olunikiweyo.

Isintakisi:

SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2;

Umzekelo:

SELECT * FROM Infostudents WHERE Fees BETWEEN 20000 AND 40000;

NGUMNTU OSEBENZAYO

Kuba akunakwenzeka ukuvavanya amaxabiso e-NULL kunye nabaqhubi bokuthelekisa (=,), sinokusebenzisa i-NULL kwaye ASINGABASEBENZI be-NULL endaweni yoko.

Isintakisi:

--Syntax for IS NULL SELECT column_names FROM table_name WHERE column_name IS NULL; --Syntax for IS NOT NULL SELECT column_names FROM table_name WHERE column_name IS NOT NULL;

Umzekelo:

SELECT StudentName, ParentName, Address FROM Infostudents WHERE Address IS NULL; SELECT StudentName, ParentName, Address FROM Infostudents WHERE Address IS NOT NULL;

NJENGOMSEBENZI

Oku kuchazwe apha ngezantsi zii-wildcards ezimbini ezisetyenziswa ngokudibeneyo nomsebenzisi we-LIKE:

  • % Ipesenti yepesenti imele iqanda, inye, okanye oonobumba abaninzi
  • _ - Isiseko esingaphantsi simele uphawu olunye

Isintakisi:

SELECT column1, column2, ... FROM table_name WHERE column LIKE pattern;

Jonga kule tafile ilandelayo kwiipateni ezahlukeneyo onokuthi uzikhankanye nomsebenzisi we-LIKE.

Umzekelo:

SELECT * FROM Infostudents WHERE StudentName LIKE 'S%';

KUMSEBENZI

Lo ngumsebenzi omfutshane weemeko ezininzi OKANYE ekuvumela ukuba uchaze amaxabiso amaninzi kwigatya LAPHO.

Isintakisi:

SELECT column_name(s) FROM table_name WHERE column_name IN (value1, value2, ...);

Umzekelo:

SELECT * FROM Infostudents WHERE Country IN ('Algeria', 'India', 'Brazil');

Phawula: Unokusebenzisa IN ngelixa ubhala Imibuzo edibeneyo . Qwalasela is syntax engezantsi:

Isintakisi:

SELECT column_name(s) FROM table_name WHERE column_name IN (SELECT STATEMENT);

UMSEBENZI OBEKHONA

Lo msebenzisi usetyenziselwa ukuvavanya ukuba irekhodi ikhona okanye ayikho.

Isintakisi:

SELECT column_name(s) FROM table_name WHERE EXISTS (SELECT column_name FROM table_name WHERE condition);

Umzekelo:

SELECT StudentName FROM Infostudents WHERE EXISTS (SELECT ParentName FROM Infostudents WHERE StudentId = 05 AND Price <25000);

BONKE umsebenzisi

Lo msebenzisi usetyenziswa nge-WHERE okanye HAVING igatya kwaye ubuya eyinyani ukuba onke amaxabiso obizo ahlangabezana nemeko.

Isintakisi:

SELECT column_name(s) FROM table_name WHERE column_name operator ALL (SELECT column_name FROM table_name WHERE condition);

Umzekelo:

SELECT StudentName FROM Infostudents WHERE StudentID = ALL (SELECT StudentID FROM Infostudents WHERE Fees > 20000);

NAKUPHI uMqhubi

Ngokufana nomqhubi BONKE, umsebenzisi NANINYE ukwasetyenzisiwe NALIPHI okanye UKUGQIBELA igatya kwaye ubuyise eyinyani ukuba nawaphi na amaxabiso okoyisa ahlangabezana nemeko.

Isintakisi:

SELECT column_name(s) FROM table_name WHERE column_name operator ANY (SELECT column_name FROM table_name WHERE condition);

Umzekelo:

SELECT StudentName FROM Infostudents WHERE StudentID = ANY (SELECT SttudentID FROM Infostudents WHERE Fees BETWEEN 22000 AND 23000);

Ngoku ndikuxelele okuninzi malunga nemiyalelo ye-DML, mandikuxelele ngokufutshane malunga nayo Imibuzo edibeneyo , Joyina , kunye Cwangcisa ukusebenza .

Imibuzo edibeneyo

Imibuzo edalekileyo yile mibuzo inombuzo wangaphandle kunye nombuzo wangaphakathi. Ke, ngokusisiseko, lo mbuzo ungumbuzo owakhiwe ngaphakathi komnye umbuzo onje NGOKUKHETHA, UKUFAKA, UKUHLAZIYA okanye UKUSUSA. Jonga umfanekiso ongezantsi:

Umzobo 3: * Ukumelwa kweMibuzo eNgekhoyo- Isifundo seMySQL *

IIJOINS zisetyenziselwa ukudibanisa imiqolo esuka kwiitafile ezimbini nangaphezulu, ngokusekwe kwikholamu enxulumene noko phakathi kwezo tafile. Ezi zilandelayo ziindidi zokujoyina:

  • Joyina ngaphakathi: Oku kujoyina kubuyisa ezo rekhodi zinamaxabiso afanayo kuzo zombini iitafile.
  • Joyina ngokupheleleyo: Oku kujoyina kubuyisa zonke iirekhodi ezinomdlalo ngasekhohlo okanye kwitafile yasekunene.
  • JOLELA: Oku kujoyina kubuyisa iirekhodi ezivela kwitafile yasekhohlo, kunye nezo rekhodi ziyanelisa imeko kwitafile yasekunene.
  • JOYELA: Oku kujoyina kubuyisa iirekhodi ezivela kwitafile yasekunene, kunye nezo rekhodi ziyanelisa imeko kwitafile yasekhohlo.

Jonga umfanekiso ongezantsi.

Umzobo 4: * Ummeli wamajoyina: I-MySQL Tutorial *

Makhe siqwalasele le theyibhile ingezantsi ngaphandle kwetafile yee-Infostudents, ukuqonda is syntax yokudibanisa.

Joyina ngaphakathi

Isintakisi:

SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.column_name = table2.column_name;

Umzekelo:

SELECT Courses.CourseID, Infostudents.StudentName FROM Courses INNER JOIN Infostudents ON Courses.StudentID = Infostudents.StudentID;

Joyina ngokupheleleyo

Isintakisi:

SELECT column_name(s) FROM table1 FULL OUTER JOIN table2 ON table1.column_name = table2.column_name;

Umzekelo:

SELECT Infostudents.StudentName, Courses.CourseID FROM Infostudents FULL OUTER JOIN Orders ON Infostudents.StudentID=Orders.StudentID ORDER BY Infostudents.StudentName;

JOYELA JOYINA

Isintaksi

SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.column_name = table2.column_name;

Umzekelo:

SELECT Infostudents.StudentName, Courses.CourseID FROM Infostudents LEFT JOIN Courses ON Infostudents.CustomerID = Courses.StudentID ORDER BY Infostudents.StudentName;

Joyina

Isintakisi:

SELECT column_name(s) FROM table1 RIGHT JOIN table2 ON table1.column_name = table2.column_name;

Umzekelo:

SELECT Courses.CourseID FROM Courses RIGHT JOIN Infostudents ON Courses.StudentID = Infostudents.StudentID ORDER BY Courses.CourseID;

Cwangcisa ukusebenza

Zintathu izinto ezibekiweyo: I-UNION, I-INTERSECT, ISETIFERENCE. Ungabhekisa kumfanekiso ongezantsi ukuqonda ukusebenza kwe-SQL.

Ngoku, niyazi ukuba i-DML commadsn. Masihambe kwicandelo lethu elilandelayo kwaye sibone imiyalelo yeDCL.

Ulawulo lweDatha (DCL) Imiyalelo

Eli candelo linemiyalelo esetyenziselwa ukulawula amalungelo kwiziko ledatha. Imiyalelo yile:

ISibonelelo

Lo myalelo usetyenziselwa ukubonelela ngamalungelo okufikelela komsebenzisi okanye amanye amalungelo kwiziko ledatha.

Isintakisi:

GRANT privileges ON object TO user;

Umzekelo:

GRANT CREATE ANY TABLE TO localhost;

UTSHINTSHE

Lo myalelo usetyenziselwa ukurhoxisa ilungelo lokufikelela lomsebenzisi elinikezwe ngokusebenzisa GRANT umyalelo.

Isintakisi:

REVOKE privileges ON object FROM user;

Umzekelo:

REVOKE INSERT ON *.* FROM Infostudents;

Ngoku, masiqhubekele kwicandelo lokugqibela lebhlog okt Imiyalelo ye-TCL.

Ulawulo loThengiso (TCL)

Eli candelo lemiyalelo lijongana ikakhulu nokuthengiselana kwesiseko sedatha. Imiyalelo yile:

ZIBOPHE

Lo myalelo ugcina yonke imicimbi kwindawo yogcino lwedatha ukusukela kwi-COMMIT yokugqibela okanye kwi-ROLLBACK command.

Isintakisi:

COMMIT;

Umzekelo:

funda i-node js pdf
DELETE FROM Infostudents WHERE Fees = 42145; COMMIT;

UMQULU

Lo myalelo usetyenziselwa ukulungisa ukuthengiselana okoko wakhupha i-COMMIT yokugqibela okanye i-ROLLBACK.

Isintakisi:

ROLLBACK;

Umzekelo:

DELETE FROM Infostudents WHERE Fees = 42145; ROLLBACK;

GCINO

Lo myalelo udala amanqaku phakathi kwamaqela entengiselwano apho ubuya khona. Ke, ngalo myalelo, unokuhambisa nje ukuthengiselana ubuye kwindawo ethile ngaphandle kokubuyisela umva kuyo yonke intengiselwano.

Isintakisi:

SAVEPOINT SAVEPOINT_NAME; --Syntax for saving the SAVEPOINT ROLLBACK TO SAVEPOINT_NAME; --Syntax for rolling back to the Savepoint command

Umzekelo:

SAVEPOINT SP1; DELETE FROM Infostudents WHERE Fees = 42145; SAVEPOINT SP2;

KHULULA ISAVEPOINT

Ungawusebenzisa lo myalelo ukususa i-SAVEPOINT oyenzileyo.

Isintakisi:

RELEASE SAVEPOINT SAVEPOINT_NAME;

Umzekelo:

RELEASE SAVEPOINT SP2;

BEKA UTSHINTSHO

Lo myalelo unika igama kwintengiselwano.

Isintakisi:

SET TRANSACTION [ READ WRITE | READ ONLY ];

Ndiyathemba ukuba ukonwabele ukufunda eli nqaku kwisifundo se-MySQL. Siyibonile imiyalelo eyahlukeneyo eya kukunceda ubhale imibuzo kwaye udlale ujikeleze kwindawo yakho yolwazi.

#mysql # uphuhliso lwewebhu

dzone.com

Isifundo se-MySQL: Isikhokelo sabaQalayo sokuFunda i-MySQL

Isifundo se-MySQL: Isikhokelo sabaQalayo sokuFunda i-MySQL-Masiqwalasele ubunzulu besifundo se-MySQL esivavanya yonke imisebenzi kunye nemiyalelo oyifunayo ukuphonononga ugcino lwedatha ...