Mashandisiro eSQL Kugadzira Chirevo Kugadzira Dhatabhesi uye Matafura

Mune ino posvo tichatarisa mashandisiro eSQL kugadzira chirevo kugadzira dhatabhesi uye matafura muSQL. Tisati tagona kugadzira tafura uye nekuwedzera data, isu tinofanirwa kutanga tagadzira dhatabhesi.

SQL Gadzira Dhatabhesi Syntax

Kugadzira dhatabhesi muSQL, tinofanirwa kushandisa CREATE DATABASE raira.

CREATE DATABASE dbname;

Semuyenzaniso:

Chirevo chinotevera cheSQL chinogadzira dhatabhesi inonzi 'ProductionDB'

CREATE DATABASE ProductionDB;

RATIDZA MABHUKU

Kuti uone iyo dhatabhesi yawakangogadzira uyezve uone iyo rondedzero yedhatabhesi mune ino system, isu tinoshandisa iyo SHOW DATABASES raira:

SHOW DATABASES;

SQL Gadzira tafura Syntax

Matafura ndiwo anovaka ezvinyorwa zvehukama. Tafura yedhatabhesi ndipo panochengeterwa dhata rese mudhatabhesi.



Kugadzira tafura muSQL, tinoda kushandisa CREATE TABLE raira.

CREATE TABLE table_name (
column_name1 datatype,
column_name2 datatype,
column_name3 datatype, .... );

column_mazita anotsanangura zita remakoramu etafura.

Iyo dhatatype inotsanangudza mhando yedata iyo inogona kubatwa nekolamu (semuenzaniso manhamba, zvinyorwa, zuva, nezvimwewo).

Ongorora:Kana tichigadzira tafura muSQL, isu tinofanirwa kudoma tafura yetafura mazita uye iyo mhando yedata vachabata.

Iwo akajairika mhando dzedata anoshandiswa ndeaya:

  • CHAR
  • VARCHAR
  • TEXT
  • DATE
  • TIME
  • TIMESTAMP

SQL GADZIRA TABLE Muenzaniso

CREATE TABLE employees (
EmployeeID int,
FirstName varchar(255),
LastName varchar(255),
Department varchar(255),
JoiningDate DATE );

Iyi iri pamusoro kodhi inogadzira tafura isina chinhu inonzi 'vashandi' ine mashanu mashanu.

Mumakoramu akataurwa, EmployeeID inogona kungobata zviyero zvepamusoro - FirstName, LastName neDhipatimendi makoramu anogona kubata anosvika makumi maviri nemashanu mavara.

JoiningDate ikholamu inobata Zuva remhando.