SQL 如何在ms access中将select sql查询的结果转换为新表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1839453/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to convert result of an select sql query into a new table in ms access
提问by silverkid
how to convert result of an select sql query into a new table in msaccess ?
如何在 msaccess 中将 select sql 查询的结果转换为新表?
回答by Fionnuala
You can use sub queries
您可以使用子查询
SELECT a,b,c INTO NewTable
FROM (SELECT a,b,c
FROM TheTable
WHERE a Is Null)
回答by Maximilian Mayerl
Like so:
像这样:
SELECT *
INTO NewTable
FROM OldTable
回答by onedaywhen
First, create a table with the required keys, constraints, domain checking, references, etc. Then use an INSERT INTO..SELECT
construct to populate it.
首先,使用所需的键、约束、域检查、引用等创建一个表。然后使用INSERT INTO..SELECT
构造来填充它。
Do not be tempted by SELECT..INTO..FROM
constructs. The resulting table will have no keys, therefore will not actually be a table at all. Better to start with a proper table then add the data e.g. it will be easier to trap bad data.
不要被SELECT..INTO..FROM
构造所诱惑。结果表将没有键,因此实际上根本不是表。最好从一个合适的表开始,然后添加数据,例如它会更容易捕获坏数据。
For an example of how things can go wrong with an SELECT..INTO
clause: it can result in a column that includes the NULL value and while after the event you can change the column to NOT NULL the engine will not replace the NULLs
, therefore you will end up with a NOT NULL column containing NULL
s!
例如,一个SELECT..INTO
子句可能会出错:它可能导致包含 NULL 值的列,而在事件发生后,您可以将列更改为 NOT NULL,引擎将不会替换NULLs
,因此您最终会得到包含NULL
s!的 NOT NULL 列
Also consider creating a 'viewed' table e.g. using CREATE VIEW
SQL DDL rather than a base table.
还可以考虑创建一个“查看过的”表,例如使用CREATE VIEW
SQL DDL 而不是基表。
回答by mavnn
If you want to do it through the user interface, you can also:
如果您想通过用户界面执行此操作,您还可以:
A) Create and test the select query. Save it.
A) 创建并测试选择查询。保存。
B) Create a make table query. When asked what tables to show, select the query tab and your saved query.
B) 创建一个生成表查询。当询问要显示哪些表时,选择查询选项卡和您保存的查询。
C) Tell it the name of the table you want to create.
C) 告诉它您要创建的表的名称。
D) Go make coffee (depending on taste and size of table)
D) 去煮咖啡(视口味和桌子大小而定)
回答by Arvo
Select *
Into newtable
From somequery