日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > 數據庫 > 數據庫應用 > PostgreSQL學習第十篇 數據庫邏輯結構介紹--數據庫

PostgreSQL學習第十篇 數據庫邏輯結構介紹--數據庫

來源:程序員人生   發布時間:2017-02-17 09:14:25 閱讀次數:6119次
PG中,數據的組織結構可以分為以下3層:

	1. 數據庫:1個PostgreSQL數據庫服務下可以管理多個數據庫;
	2. 表、索引:注:1般的PG中,表的術語叫relation,而其他數據庫中為table
	3. 數據行:注:PG中行的術語1般為tuple,而在其他數據庫中則為row

在PostgreSQL中,1個數據庫服務(或叫實例)下可以有多個數據庫,而1個數據庫不能屬于多個實例。但是在Oracle中,1個實例只能有1個數據庫,但1個數據庫可以在多個實例中(rac)

數據庫基本操作:創建數據庫、刪除數據庫、修改數據庫等

創建數據庫:
create database db_name;
可以指定所屬用戶、模板(默許為templete1)、字符編碼,表空間等

修改數據庫:
alter database db_name with option;

可以修改連接限制、重命名數據庫、修改數據庫所屬用戶等

刪除數據庫:
drop database db_name;

示例:
postgres=# \l+
                                                                    List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   |  Size   | Tablespace |                Description                 
-----------+----------+----------+-------------+-------------+-----------------------+---------+------------+--------------------------------------------
 postgres  | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ |                       | 7359 kB | pg_default | default administrative connection database
 template0 | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ | =c/postgres          +| 7225 kB | pg_default | unmodifiable empty database
           |          |          |             |             | postgres=CTc/postgres |         |            |
 template1 | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ | =c/postgres          +| 7225 kB | pg_default | default template for new databases
           |          |          |             |             | postgres=CTc/postgres |         |            |
(3 rows)

postgres=# create database test owner=postgres template=template1 encoding=utf8 tablespace=pg_default connection limit=⑴;
CREATE DATABASE
postgres=# \l+
                                                                    List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   |  Size   | Tablespace |                Description                 
-----------+----------+----------+-------------+-------------+-----------------------+---------+------------+--------------------------------------------
 postgres  | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ |                       | 7359 kB | pg_default | default administrative connection database
 template0 | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ | =c/postgres          +| 7225 kB | pg_default | unmodifiable empty database
           |          |          |             |             | postgres=CTc/postgres |         |            |
 template1 | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ | =c/postgres          +| 7225 kB | pg_default | default template for new databases
           |          |          |             |             | postgres=CTc/postgres |         |            |
 test      | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ |                       | 7225 kB | pg_default |
(4 rows)

postgres=# alter database test rename to testn;
ALTER DATABASE
postgres=# create tablespace test location '/home/postgres/test';
CREATE TABLESPACE
postgres=# alter database testn tablespace test;
ALTER DATABASE
postgres=# \l+
                                                                    List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   |  Size   | Tablespace |                Description                 
-----------+----------+----------+-------------+-------------+-----------------------+---------+------------+--------------------------------------------
 postgres  | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ |                       | 7359 kB | pg_default | default administrative connection database
 template0 | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ | =c/postgres          +| 7225 kB | pg_default | unmodifiable empty database
           |          |          |             |             | postgres=CTc/postgres |         |            |
 template1 | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ | =c/postgres          +| 7225 kB | pg_default | default template for new databases
           |          |          |             |             | postgres=CTc/postgres |         |            |
 testn     | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ |                       | 7225 kB | test       |
(4 rows)

postgres=#
postgres=# drop database test;
ERROR:  database "test" does not exist
postgres=# drop database if exists test;
NOTICE:  database "test" does not exist, skipping
DROP DATABASE
postgres=# drop database if exists testn;
postgres=# \l+
                                                                    List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   |  Size   | Tablespace |                Description                 
-----------+----------+----------+-------------+-------------+-----------------------+---------+------------+--------------------------------------------
 postgres  | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ |                       | 7359 kB | pg_default | default administrative connection database
 template0 | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ | =c/postgres          +| 7225 kB | pg_default | unmodifiable empty database
           |          |          |             |             | postgres=CTc/postgres |         |            |
 template1 | postgres | UTF8     | en_US.UTF⑻ | en_US.UTF⑻ | =c/postgres          +| 7225 kB | pg_default | default template for new databases
           |          |          |             |             | postgres=CTc/postgres |         |            |
(3 rows)


 

生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 亚洲永久精品国产 | 免费成人在线看 | 欧美性猛交xxxx黑人交 | 中文字幕精品一区 | 日韩av成人在线观看 | 激情综合激情五月 | 久久久激情 | 欧美日韩精品综合 | 国产欧美精品一区二区 | 福利精品 | 欧美在线视频二区 | 日韩极品在线 | 久久生活片 | 午夜av电影 | 亚洲午夜精品在线 | 美女日日日 | 国产成人精品久久久 | 日韩欧美在线免费 | 亚洲永久 | 约啪视频 | 免费黄色一级 | 精一区二区三区 | 日韩中文字幕精品 | 日韩欧美久久 | 久久99精品久久久久久久久久久久 | 国产精品午夜在线 | 日韩欧乱色一区二区三区在线 | 粉嫩精品一区二区三区在线观看 | 精品久久网站 | 午夜视频在线免费观看 | 国产在线污 | 国产精品久久久久久亚洲毛片 | 日韩三级在线观看 | 欧美综合在线观看 | 久久骚 | 精品九九 | 最新国产露脸在线观看 | 日韩中文字幕在线播放 | 99热久久是国产免费66 | 成人性视频免费网站 | ...99久久国产成人免费精品 |