我有以下脚本来创建一个表:
-- Create State table. DROP TABLE IF EXISTS "State" CASCADE; CREATE TABLE "State" ( StateID SERIAL PRIMARY KEY NOT NULL,StateName VARCHAR(50) );
它在PgAdmin的查询工具中运行良好.但是当我尝试使用psql从命令行运行它时:
psql -U postgres -d dbname -f 00101-CreateStateTable.sql
我收到语法错误,如下所示.
2: ERROR: Syntax error at or near "" LINE 1: ^ psql:00101-CreateStateTable.sql:6: NOTICE: CREATE TABLE will create implicit sequence "State_stateid_seq" for serial column "State.stateid" psql:00101-CreateStateTable.sql:6: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "State_pkey" for table "State" CREATE TABLE