pgsql常用命令

导入csv文件

copy public.test(oid,title, shijian, uid) from 'D:/test.csv' csv header;

查询结果更新到表

UPDATE public.userm
	SET (cardno)=(select "SFZ" from tst_sys_user where tst_sys_user."USERNAME"=userm.name limit 1)
	WHERE uid>2064

自增ID与实际ID不统一

Select setval('kecheng_id_seq', 1334)

修改密码

ALTER USER postgres WITH PASSWORD '123456';

查询结果插入到表

insert into res (title, url) (select title, url from res_o where id=1092 order by id)

强制转大写 upper/小写 lower

UPDATE public.userm
SET pwd=upper(pwd)
WHERE uid>0

修改数据类型

ALTER TABLE jifen ALTER COLUMN shijian
TYPE TIMESTAMP USING to_date(shijian, 'DD/MM/YYYY HH24:MI:SS')::date;

posted @ 2022-08-18 15:09  Xyang  阅读(175)  评论(0编辑  收藏  举报
hi