gpt4 book ai didi

MySql (Windows Server) - 在特定文件夹中创建表

转载 作者:行者123 更新时间:2023-11-29 06:34:45 24 4
gpt4 key购买 nike

我试图在 MySql 上创建一个表,指定 DATAINDEX DIRECTORY 命令。问题是我的服务器是Windows平台。

当我尝试时:

CREATE TABLE db.tb (tb_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY) DATA DIRECTORY 'd:\Abc';

它给我一个错误。

Error Code: 1210. Incorrect arguments to DATA DIRECTORY

最佳答案

你的声明应该是

CREATE TABLE db.tb (
tb_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
)
ENGINE=InnoDB
DATA DIRECTORY='d:/Abc';

CREATE TABLE db.tb (
tb_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
)
ENGINE=InnoDB
DATA DIRECTORY='d:\\Abc';

因为要在字符串中写一个反斜杠,你必须将它加倍,而且正如 Syed Ali Taqi 提到的那样,你也缺少 =

您应该检查是否启用了 innodb_file_per_table 配置选项:

SELECT  @@innodb_file_per_table; -- should return 1

Documentation

注意:

在 InnoDB 的情况下,不需要 INDEX DIRECTORY,因为 .idb 文件同时包含数据和索引,see manual :

Each InnoDB table created using the file-per-table mode goes into its own tablespace file, with a .ibd extension, inside the database directory. This file contains the table data and any indexes for the table. File-per-table mode, controlled by the innodb_file_per_table option, affects many aspects of InnoDB storage usage and performance, and is enabled by default in MySQL 5.6.7 and higher.

关于MySql (Windows Server) - 在特定文件夹中创建表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25612167/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com