有没有获取表名和创建表的常规SQL方法? [英] Is there any general SQL way to get tables names and create tables?

查看:98
本文介绍了有没有获取表名和创建表的常规SQL方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表名是指普通的旧表的名称(不是查询或类似的名称)。这是因为我正在研究一个当前连接到Jet引擎的项目,除其他功能外,它还显示了用户可以双击以查看某些特定表格内容的表格列表。但是现在我希望用户能够从已安装引擎的列表中更改引擎。但是,要使我的程序与其他引擎一起使用,就需要以一种适用于每个SQL引擎(或至少大多数SQL引擎)的方式获取表名。实际上,我还需要能够获取特定表的所有列名,并且还需要以一种适用于所有可能的引擎的方式创建 CREATE TABLE查询(因为用户可以通过向导,然后我的程序生成查询)。实际上,我非常怀疑这是否可行,但是据我所知,Visual Studio可以通过向导为不同的数据库引擎创建表。他们如何做到这一点?对于每个可能的SQL引擎,我都必须有一个不同的创建表查询吗?

With "table names" I mean just the name of normal (not queries or stuff like that), plain old tables. This is because I'm working on a project that currently connects to the Jet engine and among other features, it shows a list of tables that the user would double click to see some specific's table contents. But now I want the user to be able to change the engine from a list of installed engines. But for my program to work with other engines it will need to get the table names in a way that will work for every SQL engine (or at least most of them). I actually also need to be able to get all the column names for a specific table, and also, be able to create a "CREATE TABLE" query in a way that will work with every possible engine (since the user can create tables from a wizard, and my program generates the query). I'm actually very doubtful that this is possible but, as far as I know, Visual Studio can create tables from a wizard for different database engines. How do they manage to do this? Will I have to have a different "CREATE TABLE" query for every possible SQL engine?

我想知道ADO是否可以提供帮助,因为它似乎以某种方式具有所有功能标准化。

I'm wondering if ADO can help with this as it seems to have everything somehow standardized.

推荐答案

不,不幸的是,据我所知,没有通用的方法来做这些事情。所有DB引擎的DDL和SQL方言略有不同,支持不同的数据类型集,以及管理元数据的不同方法等。如果保持功能的绝对最低分母,我猜您可以依靠标准SQL / DDL,但这

No, unfortunately there is no general way to do these things as far as I know. All DB engines have slightly different dialects of DDL and SQL, support different sets of data types, and different ways of managing their metadata etc. If you keep to the absolute lowest denominator of features I guess you could rely on standard SQL/DDL but that will be very limited.

通常,这可以通过创建一个抽象数据层来解决,该抽象数据层具有处理不同的几种不同实现。

Usually this is solved by creating an abstract data layer with several different implementations which handles the differences.

ADO仅解决了部分问题,因为它提供了用于将查询发送到数据库的通用接口,但是查询中的SQL必须由客户端指定。

ADO only solves part of the problem as it offers a common interface for sending queries to a database but the SQL in the queries have to be specified by the client.

这篇关于有没有获取表名和创建表的常规SQL方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆