Быстрый старт
Развертывание
Моделирование данных
Подключение
Запись данных
Миграция
Запросы
Операции и обслуживание
Типовое обслуживание
Секционирование
Резервное копирование и восстановление
Масштабирование
Зеркалирование
Управление ресурсами
Безопасность
Мониторинг
Настройка производительности
Устранение неполадок
Справочник
Руководство по инструментам
Типы данных
Хранилище данных
Выполняющая система
Потоковая передача
Восстановление после сбоев
Конфигурация
Индексы
Расширения
Справочник по SQL
Часто задаваемые вопросы
gpstart -a # Start the cluster
gpstop -a # Stop the cluster (if there are active sessions, shutdown will hang)
gpstop -a -M fast # Stop the cluster quickly
gpstop -ar # Restart the cluster, wait for currently running SQL to finish (will hang if sessions exist)
gpstop -ar -M fast # Restart the cluster quickly
gpstop -u # Reload configuration files
gpstate # Display cluster status
gpstate -s # Display the status of the entire MatrixDB cluster
gpstate -e # Display mirror segment status
gpstate -m # Display mirror list
gpstate -f # Display standby master information
Показать значение конфигурационного параметра:
gpconfig -s {GUC}
# Example: Check maximum connection limit
gpconfig -s max_connections
Изменить значение конфигурационного параметра:
gpconfig -c {GUC} -v {Value} -m {Value} # -m sets value on master, -v sets value on segments
gpconfig -c {GUC} -v {Value} # If -m is omitted, master uses same value as segments
# Examples:
gpconfig -c max_connections -v 1000 -m 300
gpconfig -c shared_buffers -v 2GB
psql -d ${db_name} -U ${user_name} -h ${ip_addr} -p ${port}
Задать переменные окружения для определения значений по умолчанию:
# Edit the profile to set defaults
vi ~/.bash_profile # Use mxadmin user; add the following variables to the file
export PGPORT=5432 # Default port
export PGUSER=mxadmin # Default username
export PGDATABASE=postgres # Default database
Немедленно применить изменения в окружении:
source ~/.bash_profile
Повторное подключение с помощью psql:
# Now running psql connects directly
psql
# This is equivalent to:
psql -d postgres -U mxadmin -h localhost -p 5432
\l List all databases.
\d List all tables, views, and sequences in the current database.
\d [table_name] Describe the structure of a specific table.
\dt Show only matching tables.
\di Show only indexes.
\dt+ table_name Show table size.
\di+ index_name Show index size.
\ds Show only sequences.
\dv Show only views.
\dm Show materialized views.
\df Show only functions.
\dn List all schemas.
\du or \dg List all roles or users.
\dp table_name \z table_name Show table access privileges.
\dx Show installed extensions.
\sf function_name Show function definition.
\h Show help for SQL commands, e.g., \h select.
\? Show list of psql commands.
\c Show current database and connection info.
\c [database_name] Connect to another database.
\e Open text editor for current query.
\x Toggle expanded output mode for query results.
\! Execute operating system command.
\o /home/postgres/test.txt Redirect output to a file; use \o alone to stop.
\drds List database or user-defined settings.
\s Show command history.
\watch 1 Re-execute previous command every 1 second.
Способ 1: Использовать утилиту createdb:
createdb test
Способ 2: Использовать SQL-команду:
psql postgres
postgres=# CREATE DATABASE test;
Способ 1: Использовать утилиту dropdb:
dropdb test
Способ 2: Использовать SQL-команду:
psql postgres
postgres=# DROP DATABASE test;