我收到了这个错误:
psql:prep6_queries.txt:2:错误:类型字符的值太长(3)
psql:prep6_queries.txt:5:错误:类型字符的值太长(3)
psql:prep6_queries.txt:8:错误:类型字符的值太长(3)
INSERT 0 1
INSERT 0 1
psql:prep6_queries.txt:27:错误:语法错误在“VALUES”或附近 第2行:VALUES('BOR','Klingon',NULL,NULL);
^
这是我的代码:
INSERT INTO Country(code, name, continent, population)
VALUES ('Borduria', 'BOR', 'Pangaea', 1000);
INSERT INTO country(code, name, continent, population)
VALUES ('Cagliostro', 'CAG', 'Pangaea', 250);
INSERT INTO country(code, name, continent, population)
VALUES ('Qumar', 'MAR', 'Pangaea', 3380);
INSERT INTO countrylanguage(countrycode, countrylanguage, isofficial, percentage)
VALUES ('BOR', 'English', NULL, NULL);
INSERT INTO countrylanguage(countrycode, countrylanguage, isofficial, percentage)
VALUES ('BOR', 'Italian', NULL, NULL);
INSERT INTO countrylanguage(countrycode, countrylanguage, isofficial, percentag
VALUES ('BOR', 'Klingon', NULL, NULL);
DELETE FROM country
WHERE population < 300;
UPDATE country
SET continent = 'Luna'
WHERE name = 'Borduria' and code = 'BOR';
INSERT INTO Country(code, name, continent, population)
VALUES ('Borduria', 'BOR', 'Pangaea', 1000);
我不知道我做错了什么。我不明白它给我的错误。是因为国家代码吗?国家/地区代码长度为3个字符。我使用了错误的引号吗?有什么建议吗?
答案 0 :(得分:3)
这里有一个明显的语法错误:
INSERT INTO countrylanguage(countrycode, countrylanguage, isofficial, percentag
-- ^^^^
-- here
VALUES ('BOR', 'Klingon', NULL, NULL);
缺少右括号和e
。修复:
INSERT INTO countrylanguage(countrycode, countrylanguage, isofficial, percentage)
VALUES ('BOR', 'Klingon', NULL, NULL);
发表评论:
INSERT INTO Country(code, name, continent, population)
VALUES ('Borduria', 'BOR', 'Pangaea', 1000);
-- ^^^^^ ^^^^^
-- code? name?
应该是:
INSERT INTO Country(name, code, continent, population)
VALUES ('Borduria', 'BOR', 'Pangaea', 1000);