Create table under a specific FileGroup WHERE 1=2(在特定文件组下创建表 WHERE 1=2)
问题描述
我有一个 WinForms 应用程序,它根据给定的表格动态创建表格,例如:
I have an WinForms application which creates tables dynamically based on a given table such as:
SELECT * INTO TempTable FROM MyTable WHERE 1=2
我希望使用上述语法在特定的 filegroup
下创建那些 Temp 表
.
I want those Temp tables
to be created under a specific filegroup
though using the above syntax.
在文件组下创建表的语法是:
The syntax to create the table under a filegroup is:
CREATE TABLE [dbo].[TempTable](
[RECORDID] [numeric](10, 0) NOT NULL,
--etc etc
) ON [TempFileGroup] TEXTIMAGE_ON [TempFileGroup]
是否可以使用我上面的语法在特定文件组下创建表?
Is it possible to use my syntax above to create the table under the specific filegroup?
推荐答案
我希望使用上述语法在特定文件组下创建这些临时表
从 SQL Server 2017+
你可以使用 ON filegroup
语法.
From SQL Server 2017+
you could use ON filegroup
syntax.
INTO子句
SELECT...INTO 在默认文件组中创建一个新表,并将查询的结果行插入其中.
SELECT…INTO creates a new table in the default filegroup and inserts the resulting rows from the query into it.
[ INTO new_table ]
[ ON filegroup]
文件组
指定将在其中创建新表的文件组的名称.指定的文件组应该存在于数据库中,否则 SQL Server 引擎会抛出错误.仅从 SQL Server 2017 开始支持此选项.
Specifies the name of the filegroup in which new table will be created. The filegroup specified should exist on the database else the SQL Server engine throws an error. This option is only supported beginning with SQL Server 2017.
来自 MSDN 的示例:
Example from MSDN:
创建一个新表作为另一个表的副本并将其加载到指定的文件组
Creating a new table as a copy of another table and loading it a specified filegroup
ALTER DATABASE [AdventureWorksDW2016] ADD FILEGROUP FG2;
ALTER DATABASE [AdventureWorksDW2016]
ADD FILE
(
NAME='FG2_Data',
FILENAME = '/var/opt/mssql/data/AdventureWorksDW2016_Data1.mdf'
)
TO FILEGROUP FG2;
GO
SELECT * INTO [dbo].[FactResellerSalesXL] ON FG2 from [dbo].[FactResellerSales]
这篇关于在特定文件组下创建表 WHERE 1=2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在特定文件组下创建表 WHERE 1=2


- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01