Get SQL Server schema via a SQL query?

后端 未结 3 2056
[愿得一人]
[愿得一人] 2021-02-19 05:33

I\'ve inherited a clunky and horribly un-documented site from a bad developer and am trying to get a look at the database schema. Unfortunately the web host is the worst I\'ve e

相关标签:
3条回答
  • 2021-02-19 06:03

    I'm not sure if simple queries like

    SHOW TABLES;
    DESCRIBE table_name;
    SHOW TABLE STATUS from table_name;
    

    are valid in MS SQL. They would also be useful

    0 讨论(0)
  • 2021-02-19 06:11

    The INFORMATION_SCHEMA schema is a good place to start:

    SELECT * FROM INFORMATION_SCHEMA.TABLES
    SELECT * FROM INFORMATION_SCHEMA.VIEWS
    

    ...and so on.

    You might also want to have a look at using SMO, an API to get at the metadata in SQL Server.

    0 讨论(0)
  • 2021-02-19 06:20

    SchemaSpy http://schemaspy.sourceforge.net/ is a great tool for analyzing existing databases. It generates html lists of table and constraints as well as a graphical representation of relationships

    0 讨论(0)
提交回复
热议问题