我们非常感谢您的帮助-尝试将数据插入表中的数据库时遇到问题。
CREATE TABLE dwr2."DimCustomers"
(
"customer_id" smallint NOT NULL,
"company_name" VARCHAR (50) NOT NULL,
"contact_name" VARCHAR (50) NOT NULL,
"contact_title" VARCHAR (50) NOT NULL,
"address" VARCHAR (50) NOT NULL,
"city" VARCHAR (50) NOT NULL,
"region" VARCHAR (50) NOT NULL,
"postal_code" VARCHAR (50) NOT NULL,
"country" VARCHAR (50) NOT NULL,
"phone" VARCHAR (50) NOT NULL,
"fax" VARCHAR (50) NOT NULL,
PRIMARY KEY ("customer_id")
)
INSERT INTO dwr2."DimCustomers" (customer_id, company_name, contact_name,
contact_title, address, city, region, postal_code, country, phone, fax)
SELECT customer_id,company_name,contact_name,contact_title,
address,city,region,postal_code,country,phone,fax
FROM public.customers where customer_id!=0;
我收到以下错误:
ERROR: operator does not exist: character <> integer
LINE 3: FROM public.customers where customer_id!=0;
^
HINT: No operator matches the given name and argument types. You might need
to add explicit type casts.
SQL state: 42883
Character: 295
所有其他表插入都可以处理现在的问题,直到达到这一水平为止……对程序的熟悉程度不足以理解该错误……我尝试了许多尝试并更改了代码。任何帮助深表感谢。 谢谢。
答案 0 :(得分:0)
教授找到了答案...
CREATE TABLE dwr.DimCustomers
(
customer_id bpchar NOT NULL,
company_name character varying(40) NOT NULL,
contact_name character varying(30),
contact_title character varying(30),
address character varying(60),
city character varying(15),
region character varying(15),
postal_code character varying(10),
country character varying(15),
phone character varying(24),
fax character varying(24),
CONSTRAINT pk_customers PRIMARY KEY (customer_id)
)
drop table dwr.DimCustomers
INSERT INTO dwr.DimCustomers (customer_id, company_name, contact_name,
contact_title,address,city,region,postal_code,country,phone,fax)
SELECT customer_id, company_name, contact_name,
contact_title,address,city,region,postal_code,country,phone,fax
from public.customers where customer_id !='DRDAN';