Обсуждение: DDLs in Transactions...?

Поиск
Список
Период
Сортировка

DDLs in Transactions...?

От
james@unifiedmind.com (James Thornton)
Дата:
How does PG handle DDL statements that are wrapped in a transaction?
Does it roll them back if one fails, or is it like Oracle?

Where is this documented?

Thanks.


Re: DDLs in Transactions...?

От
"Mark Pritchard"
Дата:
Looks like it supports transactions:

[postgres@drow postgres]$ /usr/local/pgsql/bin/psql template1
Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms      \h for help with SQL commands      \? for help on internal slash commands
    \g or terminate with semicolon to execute query      \q to quit
 

template1=# begin;
BEGIN
template1=# create table intransaction (field1 int);
CREATE
template1=# rollback;
ROLLBACK
template1=# select * from intransaction;
ERROR:  Relation 'intransaction' does not exist
template1=# begin;
BEGIN
template1=# create table intransaction (field1 int);
CREATE
template1=# commit;
COMMIT
template1=# select * from intransaction ;field1 
--------
(0 rows)

template1=# begin;       
BEGIN
template1=# drop table intransaction;
DROP
template1=# rollback; 
ROLLBACK
template1=# select * from intransaction ;field1 
--------
(0 rows)

template1=# begin;
BEGIN
template1=# drop table intransaction;
DROP
template1=# commit;
COMMIT
template1=# select * from intransaction;
ERROR:  Relation 'intransaction' does not exist
template1=# 

Cheers,

Mark Pritchard

> -----Original Message-----
> From: pgsql-hackers-owner@postgresql.org
> [mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of James Thornton
> Sent: Sunday, 30 December 2001 8:12 AM
> To: pgsql-hackers@postgresql.org
> Subject: [HACKERS] DDLs in Transactions...?
> 
> 
> How does PG handle DDL statements that are wrapped in a transaction?
> Does it roll them back if one fails, or is it like Oracle?
> 
> Where is this documented?
> 
> Thanks.
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
>