You might want to look at the |
I too have wondered if SQL Anywhere had some sort of system procedures to extract DDL from any type of database object. Of course, some of these things can be queried by extracting information directly from the system tables, but that feels a bit hacky. SQL Anywhere does support some ASE procedures which get DDL information for procedures, indexes, and views (sp_helptext), but nothing for tables. As mentioned, you can select any object in Sybase Central and copy the DDL to your clipboard. In your case, this is of no use. With the help of a packet sniffer, I have found that Sybase Central is actually querying the system tables for table/column information and building the DDL itself. Manually building the DDL, or using dbunload, may be your only options. If you're going to use dbunload, yes, you're right, it's overkill. I would suggest perhaps running dbunload only intermittently and storing the results in memcache or some other temporary location. It's extra maintenance and complexity to your program, but should be sufficient unless the table schema changes very often. It would be nice to have system procedures that can retrieve the schema of any object, much like the "copy and paste" functionality within Sybase Central. |
I've tried to make my own Version Control System inside a database for all db objects and used the following function and view. It's quite old (ASA 8) and not complete (indexes, foreign keys, ...) but it's a start.
I also used it to search for specific code segments, before this functionality was available in Sybase Central.
|
The SQL Anywhere dbunload.exe utility can be used to write all the schema to a text file. Use the -n option to do just the schema, not the data. The new -no option sorts the CREATE TABLE statements in alphabetic order. You can do this from Sybase Central, but I'm a command-line kinda guy so I'll let other people talk about the wizards. The following blog post talks about using dbunload to answer "Question: How do I compare the schemas of two SQL Anywhere databases?"... http://sqlanywhere.blogspot.com/2009/10/comparing-database-schemas-improved.html If dbunload-to-text-file is not what you're looking for, maybe you could refine your question (make it more specific... point to the SQL Server feature(s) you are talking about)... or ask it as a new question, the more questions the better. And congratulations on posting the second question! (it's really the first question, if you exclude cheaters like the site administrator, i.e., me :) 1
I would need to get the DDL for an individual object. dbunload may work but it may be over kill. More information: I'm providing users with a list of database objects (e.g. tables, procedures etc.). They have the ability to click on an object and see the DDL for that object. Procedures is easy, I can get the syntax from system tables. I can also get table syntax from system tables but I would have to really know what I'm doing in order to put it all together. |
There is a simple tool the DDL Extractor which iterates over the entire server, writing ddl scripts to a local directory. http://www.antipodeansoftware.com/Home/Products |