On 04/03/12 11:13 AM, leaf_yxj wrote:
Hi John, Thanks for your reply. Just to confirm : so truncate table
means the space will be reclaim for reuse ???
yes, all the tablespace is immediately returned to the file system when
the transaction with the TRUNCATE statement commits.
--
john r pi
If You mean parent and child tables as connected by relation (primery key -
foreign key) then child table will be truncated regardless the relation
type, if CASCADE exists.
This applies to PG 9.1.3 (I've got only this version).
Regards,
Bartek
2012/4/3 leaf_yxj
> Hi Bartek
> One more question,
On 04/03/12 10:49 AM, leaf_yxj wrote:
--- I amn't sure what's differences between truncate and delete in
postgresql. Could you do me a favour to tell me about this.
delete has to go through and flag each tuple for deletion so vacuum can
eventually go through and reclaim them for reuse. trunc
One more thing:
TRUNCATE has option CASCASE:
http://www.postgresql.org/docs/9.1/static/sql-truncate.html
I don't remember since when, but 9.X has this option.
Another thing: Do You really need this function.
AFAIK since 8.4 postgres has TRUNCATE privilage on Table
http://www.postgresql.org/do
I think you need a space there:
>
>EXECUTE 'TRUNCATE TABLE ' || quote_ident(tablename) || ' CASCADE;';
>
indeed, that is my fault - sorry
> > EXCEPTION
> > WHEN undefined_table THEN
> > RAISE EXCEPTION 'Table "%" does not exists', tablename;
>
> It's really a pretty b
leaf_yxj writes:
> ***
> CREATE OR REPLACE FUNCTION truncate_t (IN tablename text)
> RETURNS VOID
> AS
> $$
> BEGIN
> EXECUTE 'TRUNCATE TABLE ' || quote_ident(tablename) || 'CASCADE;';
I think you need a space there:
EXECUTE '
On 04/03/2012 07:01 AM, leaf_yxj wrote:
***
CREATE OR REPLACE FUNCTION truncate_t (IN tablename text)
RETURNS VOID
AS
$$
BEGIN
EXECUTE 'TRUNCATE TABLE ' || quote_ident(tablename) || 'CASCADE;';
EXCEPTION
WHEN undefined_table