多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > 數(shù)據(jù)庫 > 數(shù)據(jù)庫應(yīng)用 > PostgreSQL學(xué)習(xí)第十篇 數(shù)據(jù)庫邏輯結(jié)構(gòu)介紹--數(shù)據(jù)庫

PostgreSQL學(xué)習(xí)第十篇 數(shù)據(jù)庫邏輯結(jié)構(gòu)介紹--數(shù)據(jù)庫

來源:程序員人生   發(fā)布時(shí)間:2017-02-17 09:14:25 閱讀次數(shù):6109次
PG中,數(shù)據(jù)的組織結(jié)構(gòu)可以分為以下3層:

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

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

數(shù)據(jù)庫基本操作:創(chuàng)建數(shù)據(jù)庫、刪除數(shù)據(jù)庫、修改數(shù)據(jù)庫等

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

修改數(shù)據(jù)庫:
alter database db_name with option;

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

刪除數(shù)據(jù)庫:
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)


 

生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 欧美精品福利视频 | jizzzz欧美| 亚洲色图欧美一区 | 麻豆精品成人免费国产片 | 欧美性猛交xxxxx按摩欧美 | 亚洲精品无码不卡 | 亚洲生活片| 欧美孕妇乱大交xxxxx | 精品午夜国产在线观看不卡 | 中国精品视频 | 爽爽视频在线观看 | 中文字字幕在线 | 久久成人免费视频 | 国产91精品福利在线观看 | 国产片一级aaa毛片视频 | 热久久视久久精品18国产 | 国产精品日韩 | 日韩精品一区二区三区视频网 | 高跟鞋性xxxxhd | 欧洲免费无线码二区5 | 免费看欧美毛片大片免费看 | 欧美亚洲尤物久久精品 | 欧美com| 国产成人精品久久一区二区三区 | 欧美一区二区三区高清不卡tv | 久久91综合国产91久久精品 | 精品国产免费第一区二区三区日韩 | 色人阁网站 | 国产亚洲精品国看不卡 | 国产精品亚洲欧美一区麻豆 | 国产一区二区福利久久 | 亚洲系列_1页_mmyy11 | 秋霞一级片 | 国产真实乱小说 | 国产精品夜色视频一区二区 | 精品九九九| 成人久久久观看免费毛片 | 亚洲免费大片 | 国产亚洲视频在线播放大全 | 综合亚洲色图 | 成人精品美女隐私漫画 |