/opt/gaussdb/app
子目录:
etc
:cgroup工具配置文件。include
:存放数据库运行所需要的头文件。lib
:存放数据库的库文件的目录。share
:存放数据库运行所需要的公共文件,如配置文件模板。/gaussdb/data
子目录
data_dnxxx
:DBnode实例的数据目录,其中主实例的目录名为“data_dnxxx”,备实例的为data_dnSxxx。xxx代表DBnode编号。/var/log/gaussdb/用户名
子目录
bin
:二进制程序的日志目录。gs_profile
:数据库内核性能日志目录。om
:OM的日志目录。例如:部分local脚本产生的日志,增删数据库节点接口的日志,gs_om接口的日志,前置接口的日志,节点替换接口的日志等。pg_audit
:数据库审计日志目录。pg_log
:数据库节点实例的运行日志目录。/opt/huawei/wisequery
子目录
script
:用于openGauss用户进openGauss管理的脚本文件。lib
:bin目录下的二进制文件依赖的库文件。在数据库主节点服务器上,切换至omm(数据库安装用户)操作系统用户环境。
su - omm
启动服务命令:
gs_om -t start
查看服务是否启动命令:
gs_om -t status
连接数据库命令:
注意
postgres=#
为默认数据库,其后为操作指令
(1)查看数据库对象
查看帮助信息:
`postgres=#` \?
切换数据库:
`postgres=#` \c dbname
列举数据库:
使用\l元命令查看数据库系统的数据库列表。
`postgres=#` \l
使用如下命令通过系统表pg_database查询数据库列表。
`postgres=#` SELECT datname FROM pg_database;
列举表:
`postgres=#` \dt
列举所有表、视图和索引:
`postgres=#` \d+
使用gsql的\d+命令查询表的属性。
`postgres=#` \d+ tablename
查看表结构:
`postgres=#` \d tablename
列举schema:
`postgres=#` \dn
查看索引:
`postgres=#` \di
查询表空间:
使用gsql程序的元命令查询表空间。
`postgres=#` \db
检查pg_tablespace系统表。如下命令可查到系统和用户定义的全部表空间。
`postgres=#` SELECT spcname FROM pg_tablespace;
查看数据库用户列表:
`postgres=#` SELECT * FROM pg_user;
查看用户属性:
`postgres=#` SELECT * FROM pg_authid;
查看所有角色:
`postgres=#` SELECT * FROM PG_ROLES;
(2)其他操作
`postgres=#`\h
`postgres=#` \c dbname
`postgres=#` \c – username
`postgres=#` \q
General
\copyright show FusionInsight LibrA usage and distribution terms
\g [FILE] or ; execute query (and send results to file or |pipe)
\h(\help) [NAME] help on syntax of SQL commands, * for all comman
ds
\parallel [on [num]|off] toggle status of execute (currently off)
\q quit gsql
Query Buffer
\e [FILE] [LINE] edit the query buffer (or file) with external editor
\ef [FUNCNAME [LINE]] edit function definition with external editor
\p show the contents of the query buffer
\r reset (clear) the query buffer
\w FILE write query buffer to file
Input/Output
\copy ... perform SQL COPY with data stream to the client host
\echo [STRING] write string to standard output
\i FILE execute commands from file
\i+ FILE KEY execute commands from encrypted file
\ir FILE as \i, but relative to location of current script
\ir+ FILE KEY as \i+, but relative to location of current script
\o [FILE] send all query results to file or |pipe
\qecho [STRING] write string to query output stream (see \o)
Informational
(options: S = show system objects, + = additional detail)
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregates
\db[+] [PATTERN] list tablespaces
\dc[S+] [PATTERN] list conversions
\dC[+] [PATTERN] list casts
\dd[S] [PATTERN] show object descriptions not displayed elsewhere
\ddp [PATTERN] list default privileges
\dD[S+] [PATTERN] list domains
\ded[+] [PATTERN] list data sources
\det[+] [PATTERN] list foreign tables
\des[+] [PATTERN] list foreign servers
\deu[+] [PATTERN] list user mappings
\dew[+] [PATTERN] list foreign-data wrappers
\df[antw][S+] [PATRN] list [only agg/normal/trigger/window] functions
\dF[+] [PATTERN] list text search configurations
\dFd[+] [PATTERN] list text search dictionaries
\dFp[+] [PATTERN] list text search parsers
\dFt[+] [PATTERN] list text search templates
\dg[+] [PATTERN] list roles
\di[S+] [PATTERN] list indexes
\dl list large objects, same as \lo_list
\dL[S+] [PATTERN] list procedural languages
\dn[S+] [PATTERN] list schemas
\do[S] [PATTERN] list operators
\dO[S+] [PATTERN] list collations
\dp [PATTERN] list table, view, and sequence access privileges
\drds [PATRN1 [PATRN2]] list per-database role settings
\ds[S+] [PATTERN] list sequences
\dt[S+] [PATTERN] list tables
\dT[S+] [PATTERN] list data types
\du[+] [PATTERN] list roles
\dv[S+] [PATTERN] list views
\dE[S+] [PATTERN] list foreign tables
\dx[+] [PATTERN] list extensions
\l[+] list all databases
\sf[+] FUNCNAME show a function's definition
\z [PATTERN] same as \dp
Formatting
\a toggle between unaligned and aligned output mode
\C [STRING] set table title, or unset if none
\f [STRING] show or set field separator for unaligned query output
\H toggle HTML output mode (currently off)
\pset NAME [VALUE] set table output option
(NAME := {
format|border|expanded|fieldsep|fieldsep_zero|footer|null|
numericlocale|recordsep|recordsep_zero|tuples_only|title|tableattr|pager})
\t [on|off] show only rows (currently off)
\T [STRING] set HTML <table> tag attributes, or unset if none
\x [on|off|auto] toggle expanded output (currently off)
Connection
\c[onnect] [DBNAME|- USER|- HOST|- PORT|-]
connect to new database (currently "postgres")
\encoding [ENCODING] show or set client encoding
\conninfo display information about current connection
Operating System
\cd [DIR] change the current working directory
\setenv NAME [VALUE] set or unset environment variable
\timing [on|off] toggle timing of commands (currently off)
\! [COMMAND] execute command in shell or start interactive shell
Variables
\prompt [TEXT] NAME prompt user to set internal variable
\set [NAME [VALUE]] set internal variable, or list all if no parameters
\unset NAME unset (delete) internal variable
Large Objects
\lo_export LOBOID FILE
\lo_import FILE [COMMENT]
\lo_list
\lo_unlink LOBOID large object operations
Available help:
ABORT CREATE TEXT SEARCH CONFIGURATION
ALTER APP WORKLOAD GROUP CREATE TEXT SEARCH DICTIONARY
ALTER APP WORKLOAD GROUP MAPPING CREATE TRIGGER
ALTER AUDIT POLICY CREATE TYPE
ALTER DATA SOURCE CREATE USER
ALTER DATABASE CREATE VIEW
ALTER DEFAULT PRIVILEGES CREATE WEAK PASSWORD DICTIONARY
ALTER DIRECTORY CREATE WORKLOAD GROUP
ALTER EXTENSION CURSOR
ALTER FOREIGN TABLE DEALLOCATE
ALTER FOREIGN TABLE FOR HDFS DECLARE
ALTER FUNCTION DELETE
ALTER GROUP DO
ALTER INDEX DROP APP WORKLOAD GROUP
ALTER LARGE OBJECT DROP APP WORKLOAD GROUP MAPPING
ALTER MASKING POLICY DROP AUDIT POLICY
ALTER NODE DROP CLIENT MASTER KEY
ALTER NODE GROUP DROP COLUMN ENCRYPTION KEY
ALTER RESOURCE LABEL DROP DATA SOURCE
ALTER RESOURCE POOL DROP DATABASE
ALTER ROLE DROP DIRECTORY
ALTER ROW LEVEL SECURITY POLICY DROP EXTENSION
ALTER SCHEMA DROP FOREIGN TABLE
ALTER SEQUENCE DROP FUNCTION
ALTER SERVER DROP GROUP
ALTER SESSION DROP INDEX
ALTER SYNONYM DROP MASKING POLICY
ALTER SYSTEM KILL SESSION DROP MATERIALIZED VIEW
ALTER SYSTEM SET DROP NODE
ALTER TABLE DROP NODE GROUP
ALTER TABLE PARTITION DROP OWNED
ALTER TABLESPACE DROP PROCEDURE
ALTER TEXT SEARCH CONFIGURATION DROP RESOURCE LABEL
ALTER TEXT SEARCH DICTIONARY DROP RESOURCE POOL
ALTER TRIGGER DROP ROLE
ALTER TYPE DROP ROW LEVEL SECURITY POLICY
ALTER USER DROP SCHEMA
ALTER VIEW DROP SEQUENCE
ALTER WORKLOAD GROUP DROP SERVER
ANALYSE DROP SYNONYM
ANALYZE DROP TABLE
ANONYMOUS BLOCK DROP TABLESPACE
BEGIN DROP TEXT SEARCH CONFIGURATION
CALL DROP TEXT SEARCH DICTIONARY
CHECKPOINT DROP TRIGGER
CLEAN CONNECTION DROP TYPE
CLOSE DROP USER
CLUSTER DROP VIEW
COMMENT DROP WEAK PASSWORD DICTIONARY
COMMIT DROP WORKLOAD GROUP
COMMIT PREPARED END
COPY EXECUTE
CREATE APP WORKLOAD GROUP EXECUTE DIRECT
CREATE APP WORKLOAD GROUP MAPPING EXPLAIN
CREATE AUDIT POLICY FETCH
CREATE BARRIER GRANT
CREATE CLIENT MASTER KEY INSERT
CREATE COLUMN ENCRYPTION KEY LOCK
CREATE DATA SOURCE MERGE
CREATE DATABASE MOVE
CREATE DIRECTORY PREPARE
CREATE EXTENSION PREPARE TRANSACTION
CREATE FOREIGN TABLE REASSIGN OWNED
CREATE FUNCTION REFRESH MATERIALIZED VIEW
CREATE GROUP REINDEX
CREATE INDEX RESET
CREATE MASKING POLICY REVOKE
CREATE MATERIALIZED VIEW ROLLBACK
CREATE NODE ROLLBACK PREPARED
CREATE NODE GROUP SELECT
CREATE PROCEDURE SELECT INTO
CREATE RESOURCE LABEL SET
CREATE RESOURCE POOL SET CONSTRAINTS
CREATE ROLE SET ROLE
CREATE ROW LEVEL SECURITY POLICY SET SESSION AUTHORIZATION
CREATE SCHEMA SET TRANSACTION
CREATE SEQUENCE SHOW
CREATE SERVER START TRANSACTION
CREATE SYNONYM TRUNCATE
CREATE TABLE UPDATE
CREATE TABLE AS VACUUM
CREATE TABLE PARTITION VALUES
CREATE TABLESPACE