Cov txheej txheem:

Yuav ua li cas koj teev tus yuam sij tseem ceeb hauv SQL lus nug?
Yuav ua li cas koj teev tus yuam sij tseem ceeb hauv SQL lus nug?

Video: Yuav ua li cas koj teev tus yuam sij tseem ceeb hauv SQL lus nug?

Video: Yuav ua li cas koj teev tus yuam sij tseem ceeb hauv SQL lus nug?
Video: Kev Muag Khoom thiab Kev Sib Cuam Tshuam Nrog Cov Neeg Qhua Yam Muaj Kev Nyab Xeeb 2024, Kaum ib hlis
Anonim

Siv SQL Server Management Studio

  1. Hauv Object Explorer, right-click lub rooj uas koj xav ntxiv qhov tshwj xeeb txwv, thiab nyem Tsim.
  2. Hauv Table Designer, nyem kab xaiv rau kab ntawv database koj xav kom txhais raws li qhov thawj tus yuam sij .
  3. Right-click tus kab xaiv rau kab thiab xaiv Set Primary Key .

Dhau li ntawd, dab tsi yog qhov tseem ceeb hauv SQL nrog piv txwv?

Tus yuam sij tseem ceeb yog qhov chaw hauv a rooj uas tshwj xeeb txheeb xyuas txhua kab / cov ntaub ntawv hauv cov ntaub ntawv rooj . Cov yuam sij tseem ceeb yuav tsum muaj cov txiaj ntsig tshwj xeeb. Ib kab ntawv tseem ceeb tsis tuaj yeem muaj NULL qhov tseem ceeb. A rooj tuaj yeem muaj tsuas yog ib qho tseem ceeb, uas yuav muaj xws li ib qho lossis ntau qhov chaw.

Tsis tas li ntawd, tus yuam sij txawv teb chaws hauv DBMS yog dab tsi? A txawv teb chaws key yog ib kem lossis pab pawg kab hauv cov rooj sib tham database uas muab kev sib txuas ntawm cov ntaub ntawv hauv ob lub rooj. Lub tswvyim ntawm referential kev ncaj ncees yog muab los ntawm txawv teb chaws key kev xav. Cov yuam sij txawv teb chaws thiab lawv qhov kev siv yog qhov nyuaj tshaj qhov tseem ceeb cov yuam sij.

Kuj Paub, ua li cas koj ntxiv tus yuam sij tseem ceeb?

Tus yuam sij tseem ceeb tuaj yeem txhais tau hauv CREATE TABLE nqe lus lossis ALTER TABLE nqe lus

  1. Tsim Cov Ntsiab Tseem Ceeb - Siv CREATE TABLE nqe lus.
  2. Tsim Cov Ntsiab Tseem Ceeb - Siv ALTER TABLE nqe lus.
  3. Tso Primary Key.
  4. Disable Primary Key.
  5. Qhib Cov Ntsiab Tseem Ceeb.

Tus yuam sij txawv teb chaws tuaj yeem ua tsis tau?

A txawv teb chaws key muaj null qhov tseem ceeb tsis tuaj yeem phim qhov txiaj ntsig ntawm niam txiv tus yuam sij , txij li niam txiv tus yuam sij los ntawm txhais ua tau tsis muaj null tus nqi. Txawm li cas los xij, a null txawv teb chaws key tus nqi yeej ib txwm siv tau, tsis hais tus nqi ntawm ib qho ntawm nws tsis yog- null ntu. Ib lub rooj ua tau muaj ntau cov yuam sij txawv teb chaws.

Pom zoo: