mysql - MySQL 中的全局变量

标签 mysql

我认为这是不可能的,但问一下也没有什么坏处。

我有这个sql文件:

LOAD DATA INFILE 'myfile.csv'
INTO TABLE TCONTACTN4DS
FIELDS TERMINATED BY ";"
LINES TERMINATED BY "\r\n"

如果INFILE选项中没有路径,则前往data/name_of_the_DB文件夹获取文件。

我可以在 infile 中放置任何路径,但假设我不知道将使用的路径,并且我不希望更改这些脚本。

我可以声明(不知 Prop 体在哪里)一个可以更改以描述路径的全局变量吗?如果可能的话我会如何使用它?

最佳答案

load data infile 上的 mysql 文档关于这一点非常明确,所以不,你不能这样做:

The server uses the following rules to locate the file:

  • If the file name is an absolute path name, the server uses it as given.

  • If the file name is a relative path name with one or more leading components, the server searches for the file relative to the server's data directory.

  • If a file name with no leading components is given, the server looks for the file in the database directory of the default database.

由于加载数据也不能在存储例程中使用,因此您甚至无法解决此限制。

关于mysql - MySQL 中的全局变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35579880/

相关文章:

删除级联的mysql不起作用

返回双行的mysql查询

php - 蛋糕PHP : how can i display count for each category?

python - 使用 python 列表中的信息删除 MYSQL 中的多行

mysql - 在联合查询中按日期排序

mysql - sqlalchemy ORM : how to give some low-level specification?

mysql - 一张表中相似的帐户名

php - 我的 sql 查询在 json 响应中返回 3 行相同的数据类型

Mysql:不推荐使用 mysql_setpermission?

mysql - 第一行创建mysql存储过程出错