如何在 PostgreSQL 上使用模式指定数据库参数的大小?
How to specify the size of a database parameters with schema on PostgreSQL?
我尝试使用 schema.sql
文件为 Heroku 中的 PostreSQL 初始化数据库,但我对 table 参数的大小有疑问。在 id int (11) auto_increment PRIMARY KEY
行中,我收到错误:
ERROR: syntax error at or near "("
LINE 2: id int(11) auto_increment PRIMARY KEY,
这是文件schema.sql
drop table if exists users;
create table users (
id int(11) auto_increment PRIMARY KEY,
name varchar(100),
email varchar(100),
username varchar(30),
password varchar(100),
register_date timestamp not null
);
这里是错误:
mike@mike-thinks:~/Programing/Rasa/myflaskapp$ heroku pg:psql < schema.sql--> Connecting to postgresql-clean-86569
NOTICE: table "users" does not exist, skipping
DROP TABLE
ERROR: syntax error at or near "("
LINE 2: id int(11) auto_increment PRIMARY KEY,
^
NOTICE: table "articles" does not exist, skipping
DROP TABLE
ERROR: syntax error at or near "("
LINE 2: id int(11) PRIMARY KEY,
^
如果我没记错(我很确定),postgresSQL 不接受 int
大小但 NUMERIC
。
你可以做到 columnName NUMERIC(11)
或者有约束,强制在范围之间
我尝试使用 schema.sql
文件为 Heroku 中的 PostreSQL 初始化数据库,但我对 table 参数的大小有疑问。在 id int (11) auto_increment PRIMARY KEY
行中,我收到错误:
ERROR: syntax error at or near "("
LINE 2: id int(11) auto_increment PRIMARY KEY,
这是文件schema.sql
drop table if exists users;
create table users (
id int(11) auto_increment PRIMARY KEY,
name varchar(100),
email varchar(100),
username varchar(30),
password varchar(100),
register_date timestamp not null
);
这里是错误:
mike@mike-thinks:~/Programing/Rasa/myflaskapp$ heroku pg:psql < schema.sql--> Connecting to postgresql-clean-86569
NOTICE: table "users" does not exist, skipping
DROP TABLE
ERROR: syntax error at or near "("
LINE 2: id int(11) auto_increment PRIMARY KEY,
^
NOTICE: table "articles" does not exist, skipping
DROP TABLE
ERROR: syntax error at or near "("
LINE 2: id int(11) PRIMARY KEY,
^
如果我没记错(我很确定),postgresSQL 不接受 int
大小但 NUMERIC
。
你可以做到 columnName NUMERIC(11)
或者有约束,强制在范围之间