pg 新手就 pgAdmin 發問

284 views
Skip to first unread message

stor...@gmail.com

unread,
Aug 27, 2007, 12:49:37 PM8/27/07
to PostgreSQL 8 DBA 專業指南中文版
我是 pg 新手,現於 xp 中學習 pg,
剛自編了一個資料表(欄位內容有大量重覆)。
在 pgAdmin 下,卻出現以下訊息。


pgAdmin III 1.8.0 b3
編輯沒有主鍵(PK)的表資料
表沒有主鍵或者OID欄位,只能查看資料。在沒有主鍵的情況下不能使用資料編輯工具插入新資料行和修改已經存在的資料。
為了編輯資料,pgAdminIII要求資料表具有主鍵,這也是一個好的資料庫設計習慣。另外還有一種替代方式:使用OID欄位創建資料表。請注意
OID在經過很長一段時間之後不能保證還是唯一的。因此使用OID作為主鍵僅僅是第二選擇。

pgAdmin III 1.6.3
Edit table data without primary key
Since the table go_to_data doesn't have a primary key or OIDs, you can
view the data only. Inserting new rows and changing existing rows
isn't possible for the Edit Data tool without primary key.
In order to edit data, pgAdmin III requires a primary key on the
table, which is a good database design practice anyway. Alternatively,
the table can be created WITH OIDS. Please note that oids are not
guaranteed to be unique over a very long period of time, so using oids
as kind-of primary key is only second choice.

我想提問下列幾個問題:
1-我看了中英文版的手冊,
但還是不了解「主鍵/primary key」及「OID」的作用,
可否能為我說明一下。

2-在 pgAdmin ,我該如何設定 「主鍵/primary key」或「OID」?

3-假如我將日常資料輸入表格內,
難免有大量重覆的!
那麼,我便不能用 pgAdmin 編輯資料?

先謝謝大家!

Kuo.C...@gmail.com

unread,
Aug 27, 2007, 2:28:09 PM8/27/07
to PostgreSQL 8 DBA 專業指南中文版
很高興又多了一個使用者

1.這是因為 pgAdmin 對無設置 pk 的表不給於編輯的限制
你可以建立或指定一個欄位為pk, 在當你做新增資料表的 gui 畫面第三個子項選單下方

2.您只是初學對pk的定義不太了解而以, 可於日後補強
非 pgAdmin 不接受你大量重複性資料
最方便的方法就是新增一個欄位,
例如"id", 資料型態為 serial (自動隨資料增加遞增值)來讓它自動跳號

stor...@gmail.com

unread,
Aug 28, 2007, 10:39:01 AM8/28/07
to PostgreSQL 8 DBA 專業指南中文版
謝謝指導。
我一直有看官方手冊,但都是似懂非懂。
日後會多來討教!


On 8月28日, 上午2時28分, "Kuo.Cha...@gmail.com" <Kuo.Cha...@gmail.com>
wrote:

Reply all
Reply to author
Forward
0 new messages