![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 6 of 6 total |
![]() |
Mon, Dec 31 2007 10:44 AM | Permanent Link |
Roy Lambert NLH Associates ![]() | Can someone give me an example of the syntax to clone a table indices, data, constraints and all?
Roy Lambert |
Mon, Dec 31 2007 7:43 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Roy,
<< Can someone give me an example of the syntax to clone a table indices, data, constraints and all? >> Use this; SCRIPT (NewTable VARCHAR, TableToCopy VARCHAR) BEGIN EXECUTE IMMEDIATE 'CREATE TABLE "'+NewTable+'" ( LIKE "'+TableToCopy+'" INCLUDING IDENTITY INCLUDING DEFAULTS INCLUDING GENERATED )'; EXECUTE IMMEDIATE 'INSERT INTO "'+NewTable+'" SELECT * FROM "'+TableToCopy+'"'; END -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Jan 1 2008 7:04 AM | Permanent Link |
Roy Lambert NLH Associates ![]() | Tim
I saw those options in the manual, but didn't, and still don't understand what they each mean, and I certainly didn't figure any of them to mean indices. Is there a reason for the LIKE rather than AS SELECT .. WITH DATA? Roy Lambert |
Tue, Jan 1 2008 12:44 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Roy,
<< I saw those options in the manual, but didn't, and still don't understand what they each mean, and I certainly didn't figure any of them to mean indices. >> Actually, you're correct. For some reason I thought that it would copy at least the constraints also, but it isn't doing so. I'll have to double-check on this, because it may be a bug (the constraints). At the very least, what I'll do is include additional options for including the constraints and/or indexes. << Is there a reason for the LIKE rather than AS SELECT .. WITH DATA? >> Yes. SELECT..WITH DATA does not copy default values, identify attributes, etc. It only copies the basic column information like the data type. -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Jan 1 2008 1:23 PM | Permanent Link |
"Ole Willy Tuv" | Tim,
<< Actually, you're correct. For some reason I thought that it would copy at least the constraints also, but it isn't doing so. I'll have to double-check on this, because it may be a bug (the constraints). >> My guess is that you excluded the constraints because this is how the LIKE clause is defined in the standard SQL specification. << At the very least, what I'll do is include additional options for including the constraints and/or indexes. >> Implementing support for constraints and indexes as additional options (vendor extension) would be a good way IMO. Ole Willy Tuv |
Wed, Jan 2 2008 4:00 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Ole,
<< My guess is that you excluded the constraints because this is how the LIKE clause is defined in the standard SQL specification. >> Yes, that is likely. ![]() << Implementing support for constraints and indexes as additional options (vendor extension) would be a good way IMO. >> Yes, there needs to be a way to copy an entire table structure rather easily. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Monday, July 15, 2024 at 07:03 PM | Privacy Policy![]() © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |