改高斯数据库语句。使用navicat从mysql导出库表结果和数据。
一、修改语句。
1、mysql中创建表名的时候用 ~`表名`->模式名.表名
2、所有的`都要去掉
3、例如建表语句:
`OBJECT_ID` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT ‘主键ID’,中的删除线位置都要去。
4、高斯数据库注释需要单独加。不能在建表的时候加上去。
5、PRIMARY KEY加在主键上,会自动创建索引,无需再手动创建。
6、mysql的datetime类型 -> timestamp
7、文本类型mediumtext ->text、longtext -> text
8、mysql导出的语句中带\r\n 无法识别。需要转成空格,具体步骤,先字符匹配转成/r/n,再正则匹配转空格。
9、内容值为sql语句。如内容里面的 state = ‘1’ 改成 state = “1”。
10、高斯加注释
– 表加注释
comment on table sire_new_db_text.datacheckrules is ‘规则表’;
– 字段加注释
COMMENT ON COLUMN sire_new_db_text.datacheckrules.checkid IS ‘主键ID’;
二、常用操作命令
授权bjs_sit用户操作reincfsit数据库所有权限
grant all privileges on database REINFFSIT to bjs_sit;
– 创建模式
create schema test_schema;
创建表
create table test_schema.emp(
id int primary key,
name varchar(50),
age int,
salary decimal(10,2)
);
–添加表注释
comment on table test_schema.emp is '员工表';
–表中插入数据
insert into test_schema.emp values(1,'zhangsan',22,5000),(2,'lisi',25,3000);
– 查询
select *from test_schema.emp;
select *fromtest_schema.emp where "name"="zhangsan';
– 修改
updatetest_schema.emp set salary=6000 where "name" = 'zhangsan';
– 删除
delete from test_schema.emp where "name" ='lisi';
– 增加表中字段
alter table test_schema.emp add department varchar(50);
– 创建索引
create indexidx emp name on test_schema.emp(name);
create indexidx emp age salary on test_schema.emp(age,salary);
查看索引
select * from pg catalog.pg indexes where schemaname = 'test_schema' and tablename ='emp'