Creating backup table

Database

Creating backup table

Syntax for creating a backup table from main table with column level and table level comments?

1 REPLY
Senior Apprentice

Re: Creating backup table

Hi,

 

Creating the backup table is straight forward. Getting the comments over is not.

 

To copy the table:

CREATE TABLE backup_table AS main_table WITH [NO] DATA;

The [NO] is optional - do you want the data or not?

 

This will not table column or table level comments.

 

To get those as part of the 'copy' command you'd have to use ARC or DSA - i.e. you 'll have to go through a real 'backup' and 'restore' process.

 

You can get the information though.

 

Table level comments are stored in DBC.TablesV.CommentString.

Column level comments are stored in DBC.ColumnsV.CommentString.

 

If you need to do this a lot then you're probably best off writing a stored procedure which would 'do it all'.

 

I don't have one but someone else reading this post might.

 

Cheers,

Dave

 

Ward Analytics Ltd - information in motion
www: http://www.ward-analytics.com