Is there a way to extract table DDL from any version of SQL Anywhere. For example, SQL Server has an assembly you can call to get pretty much any information from the database, including DDL for DB objects.
Thanks,
Brad
| Welcome ... | |||
|
... Visiting Newsgroup Users!
See "What makes SQLA different from the newsgroups?" in the FAQ. |
|||
|
1
|
|
|
|
|
|
You might want to look at the |
||
|
|
|
|
You can also copy and paste individual database objects from Sybase Central into a text editor (eg notepad) where you get the DDL for that object. |
||
|
|
|
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. |
||
|
|
|
|
Brad: Ralph's fresh answer prompted me to take another look and read your comments. No, there isn't any facility like what you want, and yes, it is sorely needed. I am personally embarrassed at how difficult it's been over the years to keep Foxhound's schema display up to date with respect to all changes, and I have profound respect for the author(s) of dbunload. I'm guessing you're trying to do the same thing. Suggestion: Describe exactly what you want, and why (make a business case), and post a new question here with the Title "Product suggestion: etcetera". |
||
|
|
|
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 :) |
||||
|
|
|
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.
|
|||
|
|
|
|
While I can not address this issue directly I can discribe what Microsoft has done. The code to provide all of the catalog information including the kind of informaton the poster is interested in has been blackboxed into a class (dll). This DLL is use by the standard management tools to provide schema information in the graphical interface. On the other hand this DLL can be referenced by a program and so you can build your own interface to the catalog tables. This is very handy, when Microsoft changed the default way a schema file was generated. I was able to find an application on Code Project that did most of what I wanted to have it the way it was before the update(sqlserver 2005). The tool had a nifty feature, table and view definition in are generated in dependency order, something the stock tools from MS will not do. Since DBUNLOAD already has all of the code for reading and extracting the information from the catalog tables if this code could be seperated out and made availabe like the code from MS as a dll it would go a long way toward increasing the number of third party tools available for ASA. Sybase should consider doing the same same for ASE. |
||||||||
|