postgresql study note

本文涉及的产品
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
简介:

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;

相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
相关文章
|
4月前
|
存储 算法 关系型数据库
【PostgreSQL】Introduction to PostgreSQL Index Types
【PostgreSQL】Introduction to PostgreSQL Index Types
31 0
【PostgreSQL】Introduction to PostgreSQL Index Types
|
1天前
|
人工智能 关系型数据库 数据库
PostgreSQL 常见问题解决方案 - ERROR: database is being accessed by other users
PostgreSQL 常见问题解决方案 - ERROR: database is being accessed by other users
|
9月前
|
存储 NoSQL 关系型数据库
An Overview of PostgreSQL & MySQL Cross Replication
An Overview of PostgreSQL & MySQL Cross Replication
64 0
|
关系型数据库 Linux Go
Postgresql Study 笔记
Postgresql Study 笔记
|
SQL 关系型数据库 数据库
PostgreSQL Tutorial | psql的使用
本文提供一系列常用的psql命令,能够帮助你快速和高效的从数据库中获取数据。 Connect to PostgreSQL database 1.使用psql 连接到数据库,回车后会提示你输入密码 [postgres@localhost ~]$ psql -dtest -Upostgres -W Password for user postgres: psql (10.
1575 0
|
SQL MySQL 关系型数据库
Why You Should Use HybridDB for MySQL for Online and Offline Data Separation
HybridDB for MySQL helps you separate online and offline data in a precise, economical, and secure way.
2350 0
Why You Should Use HybridDB for MySQL for Online and Offline Data Separation
|
SQL Oracle 关系型数据库
A Note on Performance Degradation When Migrating from Oracle to MySQL
MySQL databases behave quite differently from Oracle databases. Databases need to be optimized after migrating from one to the other.
2371 0