I want to point out that the problem is more subtle than you may think
Indeed. The difference between two versions of a table can be missing columns, which is fairly easy to manage, or more subtle things like NULL/NOT NULL, primary key, constraints, and a host of other things.
Consider Sybase's CREATE TABLE syntax:
create table [database .[owner ].]table_name (column_name datatype
[default {constant_expression | user | null}]
{[{identity | null | not null}]
[off row | [ in row [ (size_in_bytes) ] ]
[[constraint constraint_name ]
{{unique | primary key}
[clustered | nonclustered] [asc | desc]
[with { fillfactor = pct, max_rows_per_page = num_rows, }
reservepagegap = num_pages }]
[on segment_name]
| references [[database .]owner .]ref_table
[(ref_column )]
[match full]
| check (search_condition)}]}
[match full]...
| [constraint constraint_name]
{{unique | primary key}
[clustered | nonclustered]
(column_name [asc | desc]
[{, column_name [asc | desc]}...])
[with { fillfactor = pct, max_rows_per_page = num_rows ,
reservepagegap = num_pages } ]
[on segment_name]
|foreign key (column_name [{,column_name}...])
references [[database.]owner.]ref_table
[(ref_column [{, ref_column}...])]
[match full]
| check (search_condition) ... }
[{, {next_column | next_constraint}}...])
[lock {datarows | datapages | allpages }]
[with { max_rows_per_page = num_rows,
exp_row_size = num_bytes,
reservepagegap = num_pages,
identity_gap = value } ]
[on segment_name ]
[ [ external table ] at pathname ]
Obviously, creating an UPDATE TABLE request that will automatically make the two versions of a table identical becomes non-trivial if all of these syntax elements need to be handled.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|