The following commands run in succession can be used to optimize a table and potentially reduce its size significantly. In this Oracle Cheat Sheet, I will show you all basic to advanced Oracle SQL commands with examples. A cheat sheet is a set of notes used for quick reference. WHERE pg_stat_activity.datname = _DBNAME_ AND pid pg_backend_pid() In this quick reference cheat sheet, we will show Oracle SQL and PostgreSQL commands with examples. SELECT pg_terminate_backend(pg_stat_activity.pid) This is useful to get rid of stale connections and when you need to perform changes, such as adding, dropping or modifying columns, tables or the whole database. The query below closes all database connections, except your current psql session. Show all items of type enum SELECT * FROM pg_enum Īdd a new option to an enum type ALTER TYPE _MYTYPE_ ADD VALUE '_NEW_OPTION_' AFTER '_EXISTING_OPTION_' Show all tables including PostgreSQL system tables SELECT * FROM pg_catalog.pg_tables This following command shows a list of all databases stored on your system, including names, owners, encodings and their sizes. Show size of a single database SELECT pg_database_size('_DBNAME_') Log in to a database sudo -u postgres psql _DBNAME_ pg_lsclustersĮxcept for the login step, the commands in this section are executed in the PostgreSQL interactive terminal psql. The command below shows meta and status information about all PostgreSQL clusters, including the Postgres version, owners, online/offline status and the directories, where the data and log files are stored. ![]() sudo -u postgres pg_dump -t _TABLENAME_ _DBNAME_ > _DBNAME_TABLENAME_.sql sudo -u postgres pg_dump _DBNAME_ > _DBNAME_.sqlīacking up a single table of a database. Create a database sudo -u postgres createdb _DBNAME_ĭelete a database sudo -u postgres dropdb _DBNAME_īacking up a complete database. The one-page guide to PostgreSQL: usage, examples, links, snippets, and more. ![]() The commands in this section are executed in a terminal window such as xterm or Gnome terminal. Names of tools that are used to perform different tasks are in italic type. ![]() SQL Injection cheatsheet,, , pentest, sqlinjection, 0. In the example commands on this page placeholder names, such as database names, that need to be replaced with actual values are written in all caps and enclosed in underscores. Ingres seems to be one of the less common database backends for web applications, so I thought it would be worth installing it and making some notes to make my next Ingres-based web app test a little easier. The commands and queries were tested on Ubuntu 15.10 with PostgreSQL 9.4 installed. This is a work-in-progress collection of commands, queries and information on working with PostgreSQL databases on Ubuntu Linux.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |