Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何更改KDb+;中的数据类型;?_Kdb_Alter Table - Fatal编程技术网

如何更改KDb+;中的数据类型;?

如何更改KDb+;中的数据类型;?,kdb,alter-table,Kdb,Alter Table,我在KDb+中创建了如下表: test:([doc_id:`symbol$()];doc_displayid:`symbol$();doc_created_date:`date$();doc_aacess_date:`timestamp$();is_native_exist:`boolean$();file_size:`real$()) 现在我想将列doc\u id的数据类型从symbol更改为int 如何更改测试表和更改数据类型?在将列转换为int之前,您需要将列转换为字符串: q)upda

我在KDb+中创建了如下表:

test:([doc_id:`symbol$()];doc_displayid:`symbol$();doc_created_date:`date$();doc_aacess_date:`timestamp$();is_native_exist:`boolean$();file_size:`real$())
现在我想将列
doc\u id
的数据类型从
symbol
更改为
int


如何更改测试表和更改数据类型?

在将列转换为int之前,您需要将列转换为字符串:

q)update "I"$string doc_id from test
doc_id| doc_displayid doc_created_date doc_aacess_date is_native_exist file_s..
------| ---------------------------------------------------------------------..
您可以使用
meta
验证新类型:

q)meta update "I"$string doc_id from test
c               | t f a
----------------| -----
doc_id          | i
doc_displayid   | s
doc_created_date| d
doc_aacess_date | p
is_native_exist | b
file_size       | e

需要先将列转换为字符串,然后才能将其转换为int:

q)update "I"$string doc_id from test
doc_id| doc_displayid doc_created_date doc_aacess_date is_native_exist file_s..
------| ---------------------------------------------------------------------..
您可以使用
meta
验证新类型:

q)meta update "I"$string doc_id from test
c               | t f a
----------------| -----
doc_id          | i
doc_displayid   | s
doc_created_date| d
doc_aacess_date | p
is_native_exist | b
file_size       | e

为什么我需要将其转换为字符串?我已检查是否不需要在转换为整数之前转换为字符串。谢谢@thomas Smyth如果您尝试直接从符号转换为int,您将发现它会抛出并出错(例如,
“I”$`123`456
)。转换为字符串基本上是两种类型之间的中间人。正如为什么必须将其转换为字符串一样:kdb中的符号是内部字符串,即所有字符串值的唯一副本存储在全局字典中,而符号只是对该字典的引用。因此,当您编写
“I”$`123
时,您实际尝试转换的是一个引用(将其视为试图更改框上的标签,而不是框中的内容!)当您编写
“I”$string`123
时,首先获得引用点的值,然后转换该值(更改框中的内容)希望这有助于我为什么需要将其转换为字符串?在转换为整数之前,我已检查是否不需要转换为字符串。谢谢@thomas Smyth如果您尝试直接从符号转换为int,您将发现它会抛出并出错(例如,
“I”$`123`456
)。转换为字符串基本上是两种类型之间的中间人。正如为什么必须将其转换为字符串一样:kdb中的符号是内部字符串,即所有字符串值的唯一副本存储在全局字典中,而符号只是对该字典的引用。因此,当您编写
“I”$`123
时,您实际上试图转换的是一个引用(将其视为试图更改框上的标签,而不是框中的内容!)当您编写
“I”$string`123
时,您首先获得引用点的值,然后转换该值(更改框中的内容),希望这会有所帮助