环境
系统平台:Linux x86-64 Red Hat Enterprise Linux 7
版本:6.0,4.5
文档用途
南大通用数据库迁移到瀚高数据库常用字段类型说明。
详细信息
GBase同HGDB数据库数据类型对比:
GBase字段类型 HGDB字段类型
BIGINT INIT8/BIGINIT
BIGSERIAL BIGSERIAL
BYTE BYTE
BOOLEAN BOOLEAN/BOOL
CHAR(n) CHAR(n)
CHARACTER(n) CHAR(n)
CHARACTER VARYING CHARACTER VARYING
DATA DATA
DATATIME DATATIME
DECIMAL DECIMAL
DOUBLE PRECISION DOUBLE PRECISION/FLOAT8
FLOAT FLOAT8
INT INT
INT8 INT8
INTERVAL INTERVAL
MONEY MONEY
NCHAR(n) NCHAR(n)
NVARCHAR(n) NVARCHAR2/VARCHAR/TEXT
NUMERIC NUMERIC
REAL REAL
SMALLFLOAT FLOAT4
SMALLINT SMALLINT
TEXT TEXT
BLOB BLOB/BYTEA
CLOB CLOB/TEXT
测试例子:
1.GBase语法:
-- drop table if exists test;
create table test(
id bigserial not null ,
name character varying(30) ,
sex varchar(1) ,
age int ,
birthday DATE NOT null default TODAY ,
address text ,
primary key (id)
);
comment on column test.id is '主键';
comment on column test.name is '姓名';
comment on column test.sex is '性别';
comment on column test.age is '年龄';
comment on column test.birthday is '出生日期';
comment on column test.address is '家庭住址';
comment on table test is '人员信息表';
INSERT INTO dbtest:test
(id, name, sex, age, birthday, address)
VALUES(4, '小明', '1', 30, '2020-11-09', '济南');
INSERT INTO dbtest:test
(id, name, sex, age, birthday, address)
VALUES(1, '张三', '1', 23, '2020-03-10', '济南');
INSERT INTO dbtest:test
(id, name, sex, age, birthday, address)
VALUES(2, '小红', '0', 25, '1996-09-11', '潍坊');
INSERT INTO dbtest:test
(id, name, sex, age, birthday, address)
VALUES(3, '李四', '1', 24, '1996-09-10', '潍坊');
2.转化后HGDB语法:
-- drop table if exists test;
create table test(
id bigserial not null ,
name character varying(30) ,
sex varchar(1) ,
age int ,
birthday DATE NOT null default now() ,
address text ,
primary key (id)
);
comment on column test.id is '主键';
comment on column test.name is '姓名';
comment on column test.sex is '性别';
comment on column test.age is '年龄';
comment on column test.birthday is '出生日期';
comment on column test.address is '家庭住址';
comment on table test is '人员信息表';
INSERT INTO test
(id, name, sex, age, birthday, address)
VALUES(4, '小明', '1', 30, '2020-11-09', '济南');
INSERT INTO test
(id, name, sex, age, birthday, address)
VALUES(1, '张三', '1', 23, '2020-03-10', '济南');
INSERT INTO test
(id, name, sex, age, birthday, address)
VALUES(2, '小红', '0', 25, '1996-09-11', '潍坊');
INSERT INTO test
(id, name, sex, age, birthday, address)
VALUES(3, '李四', '1', 24, '1996-09-10', '潍坊');