天天看點

opengauss資料庫使用方法一、啟動服務二、連接配接預設資料庫postgres。當結果顯示為如下資訊,則表示連接配接成功。三、建立使用者,并檢視系統中所有使用者 select * from pg_user;四、建立資料庫,資料庫的所有者是第10步建立的使用者,并檢視所有資料庫\l五、退出目前資料庫\q,以第10步建立的使用者登入第11步建立的資料庫六、修改使用者名作為終端指令行提示符一些個人感想

一、啟動服務

gs_om -t start           

注解:openGauss提供了gs_om工具對openGauss資料庫執行個體進行維護,包括啟動openGauss、停止openGauss、查詢openGauss狀态、生成靜态配置檔案、重新整理動态配置檔案、顯示幫助資訊和顯示版本号資訊的功能。

當結果顯示為如下資訊,則表示啟動成功。

gsql ((openGauss 1.0.0 build 290d125f) compiled at 2020-05-08 02:59:43 commit 2143 last mr 131 
Non-SSL connection (SSL connection is recommended when requiring high-security) 
Type "help" for help. 
 
postgres=#            

二、連接配接預設資料庫postgres。

[omm@ecs-c9bf ~]$gsql -d postgres -p 26000 -r             

當結果顯示為如下資訊,則表示連接配接成功。

gsql ((openGauss 1.0.0 build 290d125f) compiled at 2020-05-08 02:59:43 commit 2143 last mr 131 
Non-SSL connection (SSL connection is recommended when requiring high-security) 
Type "help" for help. 
 
postgres=#            

其中,postgres為openGauss安裝完成後預設生成的資料庫。初始可以連接配接到此資料庫進行新資料庫的建立。26000為資料庫主節點的端口号,需根據openGauss的實際情況做替換,請确認連接配接資訊擷取。

引申資訊:

  • 使用資料庫前,需先使用用戶端程式或工具連接配接到資料庫,然後就可以通過用戶端程式或工具執行SQL來使用資料庫了。
  • gsql是openGauss資料庫提供的指令行方式的資料庫連接配接工具。

三、建立使用者,并檢視系統中所有使用者 select * from pg_user;

CREATE USER student  IDENTIFIED BY 'student@ustb2021';           

四、建立資料庫,資料庫的所有者是第10步建立的使用者,并檢視所有資料庫\l

create database studentdb owner student;           

五、退出目前資料庫\q,以第10步建立的使用者登入第11步建立的資料庫

gsql -d studentdb -U student -p 26000 -W student@ustb2021 -r;           

六、修改使用者名作為終端指令行提示符

studentdb=> \echo :PROMPT1
%/%R%# 
studentdb=>\set PROMPT1 %/-%n%R%#
studentdb-student=>           

一些個人感想

opengauss資料庫有點類似postgresSQL,和本人一直在用的sql server文法語句有許多細節的不同,如opengauss在資料庫和表之間還有一層schema(模式)的關系,需要學習者注意