<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - Jak dodac klucz podstawowy do już istniejącej tabeli?]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=2257&amp;type=atom"/>
	<updated>2015-02-09T21:55:12Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=2257</id>
		<entry>
			<title type="html"><![CDATA[Odp: Jak dodac klucz podstawowy do już istniejącej tabeli?]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=5436#p5436"/>
			<content type="html"><![CDATA[Prymitywna bo to odtworzenie działania systemu, przy nadawaniu wartości dla primary key. Jest to metoda bardzo wydajna ale wymaga wykonania kilku kroków. Można to zrobić oczywiście jednym update-em ale wtedy nie musi być tak szybko, za to mniej jest pisania.]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2015-02-09T21:55:12Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=5436#p5436</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: Jak dodac klucz podstawowy do już istniejącej tabeli?]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=5435#p5435"/>
			<content type="html"><![CDATA[[quote=c_michal]Najbardziej prymitywne rozwiązanie to:
krok 1: ustalenie max wartości dla pola ID w tabeli - select max(id)+1 as start from tabela;
Krok 2: utworzenie sekwencji CREATE SEQUENCE pk_id_seq START tu_wpisz_wartosc_z_kroku_1;
krok 3: poprawiamy pola id - update tabela set id=nextval ('pk_id_seq') where id is null;
krok 4: kasujemy zbędną sekwencje - DROP SEQUENCE pk_id_seq;[/quote]


A jakie rozwiązanie byłoby mniej "prymitywne"?]]></content>
			<author>
				<name><![CDATA[wiesiek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1682</uri>
			</author>
			<updated>2015-02-07T07:15:43Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=5435#p5435</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: Jak dodac klucz podstawowy do już istniejącej tabeli?]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=5434#p5434"/>
			<content type="html"><![CDATA[Super.
Dziękuje.]]></content>
			<author>
				<name><![CDATA[wiesiek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1682</uri>
			</author>
			<updated>2015-02-03T14:55:55Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=5434#p5434</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: Jak dodac klucz podstawowy do już istniejącej tabeli?]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=5433#p5433"/>
			<content type="html"><![CDATA[Najbardziej prymitywne rozwiązanie to:
krok 1: ustalenie max wartości dla pola ID w tabeli - select max(id)+1 as start from tabela;
Krok 2: utworzenie sekwencji CREATE SEQUENCE pk_id_seq START tu_wpisz_wartosc_z_kroku_1;
krok 3: poprawiamy pola id - update tabela set id=nextval ('pk_id_seq') where id is null;
krok 4: kasujemy zbędną sekwencje - DROP SEQUENCE pk_id_seq;]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2015-02-03T07:24:45Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=5433#p5433</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Jak dodac klucz podstawowy do już istniejącej tabeli?]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=5432#p5432"/>
			<content type="html"><![CDATA[Dodałem kolumnę id
integer

po komendzie alter table adresy1 add primary key (id);

jest odpowiedź:
kolumna "id" zawiera puste wartosci

Jak ją napełnic wartościami? Na piechote sie nie da. zbyt ich dużo]]></content>
			<author>
				<name><![CDATA[wiesiek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1682</uri>
			</author>
			<updated>2015-02-02T14:59:39Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=5432#p5432</id>
		</entry>
</feed>
