如何在postgreSQL中识别citext类型的列
我创建了一个示例表,第一列定义为citext如何在postgreSQL中识别citext类型的列,sql,postgresql,Sql,Postgresql,我创建了一个示例表,第一列定义为citext CREATE TABLE users ( nick CITEXT PRIMARY KEY, pass TEXT NOT NULL ); 当我尝试执行以下查询以获取列名及其数据类型时,nick列的数据类型将作为用户定义的返回 select column_name, data_type from information_schema.columns where table_name = 'users'; column_name | d
CREATE TABLE users (
nick CITEXT PRIMARY KEY,
pass TEXT NOT NULL
);
当我尝试执行以下查询以获取列名及其数据类型时,nick列的数据类型将作为用户定义的返回
select column_name, data_type from information_schema.columns
where table_name = 'users';
column_name | data_type
1 nick | USER-DEFINED
2 pass | text
我可以通过查询postgreSQL中的任何表来确定列nick是否为citext类型吗?您需要使用列
udt\u name
,而不是数据类型
:
create type compfoo AS (f1 int, f2 text);
create table compfoo_table (cp compfoo);
select udt_name from information_schema.columns where column_name = 'cp';
-- drop table compfoo_table;
-- drop type compfoo;
谢谢。这正是我想要的。