Convert database table structure to XSD format

Is there any way to convert a struture table into a MySQL or Oracle database in the XSD (XML Schema Definition) format?

Thanks.

+4
source share
2 answers

Yes, but it's pretty complicated. You want to run the SHOW CREATE TABLE <tablename> query, and it will return the full table creation statement (in CREATE TABLE syntax order).

Then you need to parse each line of the create table syntax using your language. Fortunately, the fields are neatly separated by newlines.

Types should be pretty easy to map to XSD types.

In cases where this is complicated, you parse the foreign key relationships - then you will need to define custom types in your XSD and refer to them accordingly.

It really comes down to your implementation. If you are looking for a portable data format that you can easily import and export from your database, then there are a number of other solutions.

0
source

Source: https://habr.com/ru/post/1300843/


All Articles