<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - Create table]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=156&amp;type=atom"/>
	<updated>2009-03-17T20:41:12Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=156</id>
		<entry>
			<title type="html"><![CDATA[Odp: Create table]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=633#p633"/>
			<content type="html"><![CDATA[Takiego if'a zawsze mi brakowało w postgresie. Jako rozwiązanie mozesz napisać funkcje, która tworzy taką tabelę jeśli jeszcze jej nie ma. Ale duzo bardziej uniwersalnym rozwiązaniem jest stworzenie funkcji, która będzie wykonywać dynamicznie jakieś polecenie (podane jako argument)
[code]create or replace function iff(varchar) returns void as
$$
begin
execute $1;
end;
$$
language plpgsql[/code]
i wywołać to na przykład tak
[code]select iff('create table qaz(i int)') where not exists (select * from pg_tables where tablename='qaz');[/code]
Uprzedzając wszelkie marudzenie wiem, że uzycie if not exists w mysql jest prostsze :).
W sumie nie spoglądałem na ostatnie wydania postgresa (może już coś takiego wymyślili). Zauważ że funkcja która podałem jest uniwersalna i może służyć nie tylko do tworzenia tabel.]]></content>
			<author>
				<name><![CDATA[rski]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=26</uri>
			</author>
			<updated>2009-03-17T20:41:12Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=633#p633</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: Create table]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=632#p632"/>
			<content type="html"><![CDATA[Podziel sie ta funkcja]]></content>
			<author>
				<name><![CDATA[grefkow]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=852</uri>
			</author>
			<updated>2009-03-17T17:13:10Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=632#p632</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: Create table]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=629#p629"/>
			<content type="html"><![CDATA[Szczęśliwcze, nie ma czegoś takiego w postgresie. Można to uzyskać pisząc prosta funkcją ale polecenia samego sobie nie ma (albo ja nic o nim nie wiem)]]></content>
			<author>
				<name><![CDATA[rski]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=26</uri>
			</author>
			<updated>2009-03-17T14:54:11Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=629#p629</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Create table]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=627#p627"/>
			<content type="html"><![CDATA[Od kilku godzin jestem szczesliwcem ktory zamienil mysql na postgres mam zapytanie jaki jest odpowiednik zapytania z mysqla
create table if not exsists ......]]></content>
			<author>
				<name><![CDATA[grefkow]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=852</uri>
			</author>
			<updated>2009-03-17T09:59:11Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=627#p627</id>
		</entry>
</feed>
