我正在尋找一種以冪等方式腳本postgreSQL模式更改的方法。 在MSSQL中,我可以做這樣的事情: if(not exists(select * from information_schema.columns where table_name = 'x' and column_name = 'y'))
begin
alter table x add y int
end
go
我這個編程PL/pgSQL函數: cols_to_select := according to a set of rules, we get the name of the columns
FOR I IN EXECUTE 'SELECT '||cols_to_select||' FROM tabl' LOOP
-- how to access to fields of record
我在PostgreSQL數據庫中有一個表或視圖的名稱,並且需要在單個pgSQL命令中刪除它。我怎麼買得起它? 我能夠選擇的形式系統表,以找出是否有這樣的名稱的任何表,但堅持了程序的一部分: SELECT count(*) FROM pg_tables where tablename='user_statistics';