<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - Dodawanie postfixa do każdej selectowanej kolumny.]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=1857&amp;type=atom"/>
	<updated>2013-06-19T12:25:50Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=1857</id>
		<entry>
			<title type="html"><![CDATA[Odp: Dodawanie postfixa do każdej selectowanej kolumny.]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4595#p4595"/>
			<content type="html"><![CDATA[Wykonaj poniższy select - generuje on gotowy SQL (select) w odpowiednim formacie, używa funkcji string_agg więc musisz mieć co najmniej 9 wersje postgresa (wygeneruje Ci tyle rekordów ile masz tabel w schemacie public), jak go dostosujesz do twoich potrzeb to będziesz miał to o co Ci chodzi

select 
'select '||string_agg((select nspname from pg_namespace n where n.oid = r.relnamespace)||'.'||r.relname||'.'||c.attname||' as '||c.attname||'_'||r.relname,', ')||' from '||(select nspname from pg_namespace n where n.oid = r.relnamespace)||'.'||r.relname as kolumna
from pg_class r
join pg_attribute c on r.oid=c.attrelid
join pg_type t on c.atttypid=t.oid
where r.relkind = 'r' and (select nspname from pg_namespace n where n.oid = r.relnamespace)='public' and c.attnum>=0 
group by r.relnamespace,r.relname
order by r.relnamespace,r.relname]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2013-06-19T12:25:50Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4595#p4595</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Dodawanie postfixa do każdej selectowanej kolumny.]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4594#p4594"/>
			<content type="html"><![CDATA[Czy można zrobić jakoś tak:
[code] select tabela1.* as tabela1.*_postfix_1
        tabela2.* as tabela2.*_postfix_2[/code]
Chodzi o to że tabele te mogą mieć kolumny o takich samych nazwach, a nie chcę wypisywać każdej kolumny z osobna.]]></content>
			<author>
				<name><![CDATA[tomek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1459</uri>
			</author>
			<updated>2013-06-19T10:59:02Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4594#p4594</id>
		</entry>
</feed>
