[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: yardim postgresql



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Merhaba,

On Thu, 2 Jun 2005 ali@linuxprogramlama.com wrote:

elimde bir tablo var bu tabloda id alanlari ayni olan alanlar var bunlari
nasil uniq hale getirebilrim daha sonra primary key lanaı tanımlamak
istiyorum.

Yeni bir id alanı tanımlanır:

ALTER TABLE t1 ADD c2 serial UNIQUE;

ve biter :)

test=# CREATE TABLE ali (a int2, b varchar(3), c varchar(3));
CREATE TABLE
test=# ALTER TABLE alo ADD c2 serial UNIQUE;
test=# INSERT INTO ali VALUES (2, 'x','y');
INSERT 516461 1
test=# INSERT INTO ali VALUES (2, 'z','t');
INSERT 516462 1
test=# INSERT INTO ali VALUES (3, 'r','s');
INSERT 516463 1
test=# INSERT INTO ali VALUES (3, 'f','g');
INSERT 516464 1
test=# SELECT * from ali ;
 a | b | c
- ---+---+---
 2 | x | y
 2 | z | t
 3 | r | s
 3 | f | g
(4 rows)

test=# ALTER TABLE ali ADD c2 serial UNIQUE;
NOT: ALTER TABLE, "ali_c2_seq.ali" serial sütunu için "c2" örtülü sequence oluşturacaktır NOT: ALTER TABLE / ADD UNIQUE "ali" tablosu için "ali_c2_key" indexi oluşturulacaktır
ALTER TABLE
test=# SELECT oid,* FROM ali;
  oid   | a | b | c | c2
- --------+---+---+---+----
 516473 | 2 | x | y |  1
 516474 | 2 | z | t |  2
 516475 | 3 | r | s |  3
 516476 | 3 | f | g |  4
(4 rows)



- --
Devrim GUNDUZ devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
http://www.tdmsoft.com.tr                      http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFCnyd+tl86P3SPfQ4RAozdAJ4nMzaHOohhQXyd4dCKA46NjvPbsQCfSHiG
KYt9q7psq+AYAzZykp5cB8U=
=x3+A
-----END PGP SIGNATURE-----

Reply to: