I cannot find any equivalent datatype for SQL_Variant in potgresql. Sql_variant is available in sql server. I am new to postgres and presently migrating from sql server to postgres.
我在potgresql中找不到SQL_Variant的任何等效数据类型。Sql_variant在sql server中可用。我对postgres并不熟悉,目前正在从sql服务器迁移到postgres。
2 个解决方案
#1
1
There is no such data type in PostgreSQL.
PostgreSQL中没有这样的数据类型。
You can either use several attributes, one for each possible type (and maybe a CHECK
constraint that assures that exactly one of them is NOT NULL
) or store binary data (type bytea
) and convert them to whatever data type you need in the application.
您可以使用几个属性,每个属性对应一个可能的类型(可能还有一个检查约束,确保其中一个不是NULL),或者存储二进制数据(类型bytea),并将它们转换为应用程序中需要的任何数据类型。
#2
1
Here is about sql_variant
link sql_variant (Transact-SQL)
下面是关于sql_variant链接sql_variant (Transact-SQL)
I would say the closest you could get is to declare a text column and store the string representations of the values.
我认为最接近的方法是声明一个文本列并存储值的字符串表示形式。
#1
1
There is no such data type in PostgreSQL.
PostgreSQL中没有这样的数据类型。
You can either use several attributes, one for each possible type (and maybe a CHECK
constraint that assures that exactly one of them is NOT NULL
) or store binary data (type bytea
) and convert them to whatever data type you need in the application.
您可以使用几个属性,每个属性对应一个可能的类型(可能还有一个检查约束,确保其中一个不是NULL),或者存储二进制数据(类型bytea),并将它们转换为应用程序中需要的任何数据类型。
#2
1
Here is about sql_variant
link sql_variant (Transact-SQL)
下面是关于sql_variant链接sql_variant (Transact-SQL)
I would say the closest you could get is to declare a text column and store the string representations of the values.
我认为最接近的方法是声明一个文本列并存储值的字符串表示形式。