postgresql study note

PostgreSQL的外键深入使用 - kenyon的个人页面 - 开源中国社区

 

pgdump -h ip -Uusername dbname >sqlfilename.sql

pgdump -Fc -h ip -Uusername dbname >*.dump

create newdbname

pg_restore -d newdbname *.dump

--创建 schema

\c dbname 切换目标数据库

create schema schemaName owner lv;

drop schema schemaName;

alter schema schemaName owner useName;

\dn 查看创建结果

ssh ip

su passwd postgres

su - postgres

 地理位置:

CREATE TABLE user_loc(

    ud char(6),

    loc1 point 

);

INSERT INTO user_loc VALUES ('a', '(1, 1.0)');

INSERT INTO user_loc VALUES ('b', '(2, 2.0)');

 select lseg '((0, 1),(1, 0))' <-> lseg '((0, 2),(2, 0))';

select point '(1,1)' <-> point '(2,2)' from user_loc; -- ok

select loc1 <-> loc2 from user_loc;  -- ok 

select ud from user_loc where a  (lseg (a.loc1 <->(select b.loc1 from user_loc b where b. )))= 1.4142135623731;

select bb.ud from user_loc aa, user_loc bb   where (lseg (aa.loc1 <-> bb.loc1)) = 1.4142135623731;

 

你可能感兴趣的:(PostgreSQL)