Cov txheej txheem:

Yuav ua li cas koj tsim tus yuam sij txawv teb chaws hauv pgAdmin 4?
Yuav ua li cas koj tsim tus yuam sij txawv teb chaws hauv pgAdmin 4?

Video: Yuav ua li cas koj tsim tus yuam sij txawv teb chaws hauv pgAdmin 4?

Video: Yuav ua li cas koj tsim tus yuam sij txawv teb chaws hauv pgAdmin 4?
Video: yuam kev ua koj txiv tsev by nuj xeem nkauj tawm tshiab 2020-2021 2024, Kaum ib hlis
Anonim

Hauv pgAdmin 4, ntawm no yog cov kauj ruam:

  1. Right-click rau ntawm lub rooj thiab xaiv Properties.
  2. Nyob rau hauv lub dialog uas tshwm, nyem qhov txwv / Foreign Key .
  3. Nyem lub + icon nyob rau sab xis ntawm lub qhov rais Tus yuam sij txawv teb chaws rooj.

Yog li ntawd, kuv yuav ntxiv tus yuam sij txawv teb chaws hauv postgresql li cas?

Ntxiv CONSTRAINT constraint_name LUB TSEV KAWM NTAWV (c1) REFERENCES parent_table (p1); Ib daim ntawv kawg thaum koj xav tau ntxiv tus yuam sij txawv teb chaws txwv nrog ON DELETE CASCADE rau lub rooj uas twb muaj lawm, koj yuav tsum ua cov kauj ruam hauv qab no: Tso cov uas twb muaj lawm txawv teb chaws key txwv. Ntxiv ib new txawv teb chaws key txwv nrog ON DELETE CASCADE kev txiav txim.

Ib sab saum toj no, Kuv yuav ua li cas khiav SQL hauv pgAdmin 4? Yog tias koj nkag mus rau cov cuab yeej Query ntawm Query Tool menu xaiv ntawm cov cuab yeej ntawv qhia zaub mov, koj tuaj yeem:

  1. Tshaj tawm ad-hoc SQL queries.
  2. Execute arbitrary SQL commands.
  3. Txuag cov ntaub ntawv tso tawm nyob rau hauv lub vaj huam sib luag tso zis rau CSV cov ntaub ntawv.
  4. Tshawb xyuas cov phiaj xwm kev ua tiav ntawm SQL nqe lus hauv cov ntawv nyeem lossis cov duab nraaj.

Ntawm no, koj ua li cas los tsim ib qho tseem ceeb hauv pgAdmin?

  1. Xaiv lub rooj koj xav tau.
  2. Ctrl + Alt + Enter lossis right-click / Properties.
  3. Xaiv "Kev txwv" tab.
  4. Nyob rau sab laug-hauv qab ntawm daim ntawv koj yuav pom qhov kev xaiv "Primary Key"
  5. Nyem ntxiv.
  6. Xaiv "Kem" tab.
  7. Xaiv kab uas koj xav tau ua tus yuam sij.
  8. Nyem ntxiv.

Koj tsim ib lub rooj hauv pgAdmin 4 li cas?

Tsim cov lus hauv pgAdmin 4 nrog autoincrement kab. Qhib pgAdmin cuab yeej. Nthuav cov nodes hauv koj cov ntaub ntawv thiab mus rau qhov Rooj node. Right click lub Rooj node thiab xaiv Tsim -> Rooj.

Pom zoo: