通过ODBC查询SQL Server DB的数据库模式?

时间:2022-03-27 12:47:52

Is there a generic way to retrieve a database schema using ODBC that works across databases?

是否有一种通用的方法来使用跨数据库的ODBC检索数据库模式?

If not, what is the easiest way to do this when the database server is MS SQL Server?

如果不是,当数据库服务器是MS SQL server时,最简单的方法是什么?

I am working with unixodbc, from Linux.

我正在使用来自Linux的unixodbc。

2 个解决方案

#1


3  

Query against the INFORMATION_SCHEMA views. Beautiful thing about using information schema is that it's a standard so it should be portable to any database that has implemented the standard.

查询INFORMATION_SCHEMA视图。使用信息模式的好处是它是一个标准,因此它应该可以移植到任何已经实现该标准的数据库。

e.g. SELECT * FROM INFORMATION_SCHEMA.COLUMNS ISC

从INFORMATION_SCHEMA中选择*。列ISC

The standard is the SQL-92 Starts at page 535

标准是SQL-92从第535页开始

#2


1  

If you want to get a list of the schema's in the database, you can use the wildcard in the SQLTables call

如果希望在数据库中获得模式的列表,可以在SQLTables调用中使用通配符

SQLTables( stmt, NULL, 0, "%", SQL_NTS, NULL, 0, NULL, 0 );

SQLTables(stmt、NULL、0、“%”、SQL_NTS、NULL、0、NULL、0);

Or something close to that.

或者类似的东西。

#1


3  

Query against the INFORMATION_SCHEMA views. Beautiful thing about using information schema is that it's a standard so it should be portable to any database that has implemented the standard.

查询INFORMATION_SCHEMA视图。使用信息模式的好处是它是一个标准,因此它应该可以移植到任何已经实现该标准的数据库。

e.g. SELECT * FROM INFORMATION_SCHEMA.COLUMNS ISC

从INFORMATION_SCHEMA中选择*。列ISC

The standard is the SQL-92 Starts at page 535

标准是SQL-92从第535页开始

#2


1  

If you want to get a list of the schema's in the database, you can use the wildcard in the SQLTables call

如果希望在数据库中获得模式的列表,可以在SQLTables调用中使用通配符

SQLTables( stmt, NULL, 0, "%", SQL_NTS, NULL, 0, NULL, 0 );

SQLTables(stmt、NULL、0、“%”、SQL_NTS、NULL、0、NULL、0);

Or something close to that.

或者类似的东西。