Backing up and restoring PostgreSQL is fairly easy using pg_dump and psql. One more complicated scenario I have run into is doing a complete database backup with pg_dump and at some point down the road needing to just split out one table and restore it. This can be a pain because of how the pg_dump organizes the .sql file it outputs. I have found the best way to do this is to use pg_dump to backup one table to understand the format of what is needed for a restore. Then search the .sql file that was output from the full pg_dump output and split out the necessary data to restore into one table. Below I provide some examples as well as syntax to use for backing up and/or restoring PostgreSQL using pg_dump and psql.
The pg_stat_activity table will show you what activity is currently happening on your PostgreSQL database server. The information will detail the database the activity is occuring on, the username initiating the activity, the length of time the acitivy has been occuring for, and much more.
Below is example output from running a SELECT query against the pg_stat_activity table. The pg_stat_activity table is located by default in the postgres database and can be accessed as shown below.
The Linux kill command is used to kill PID’s or process ID’s. This command is beneficial for numerous reasons typically for run away processes, processes caught in some sort of loop, to kick users from a system, or any other number of reasons.
Typically kill is used in the below format with 12345 being the PID in this example.
- [root@server ~]# kill 12345
If the process will not die from using the above command the -9 switch can be added to force it to stop as shown below.
This post will explain how to post notes from Microsoft OneNote into the WordPress admin. When you copy and paste from most Microsoft products into a visual editor such as TinyMCE that WordPress uses you will typically include a bunch of unwanted tags from the Microsoft application. These tags will make it complicated to format correctly and can even spill over outside of your post and cause issues with your entire WordPress page. The method to input this data into WordPress will work with any of the Microsoft products such as Microsoft OneNote and Microsoft Word.
Below is an example of some basic formatted text copied directly from MS OneNote and pasted into WordPress’s visual editor.
To create a PL/pgSQL stored procedure, copy and paste a dummy procedure like this into the “Execute arbitrary SQL queries” window in PgAdmin 1.8.4: