How to add a Auto Increment Column to a PostgreSQL table


Unfortunately Postgresql does not have Auto Increment columns so instead we create a Sequence that will act as a counter First we’ll need to create a sequence that we want to attch to our table CREATE SEQUENCE mytable_primary_id_seq; Then we need to assign the sequence to the column in our table that will act as the Autoincrement column ALTER TABLE mytable     ALTER COLUMN primary_id...

How to add a comment to a PostgreSQL table


If you have a table with the name transactions and you need to add a comment to this table for future references you can add a comment by using the code below, replacing the table name and the comment to suite your needs.

COMMENT ON TABLE "transaction" IS 'This table keeps a log of all orders that went through the website';

ERROR: permission denied for sequence


Problem: PHP Warning:  pg_query(): Query failed: ERROR:  permission denied for sequencename in PostgreSql
To fix this problem, change the owner to the role that needs to access this sequence

ALTER TABLE sequencename OWNER TO rolename;

Change sequencename to your sequence name and rolename to the owner

How to format date fields using MySQL


Ever wondered how to change the output of the date format using MySQL? If you are constantly logging you’re data it’s more likely that you will use DATETIME fields in a MySQL table field to track the dates of events. What happens if you need to display the date in Human readable format? By using the DATE_FORMAT() function you’ll be able to manipulate the Date in almost any...

How to backup a MySQL database in Ubuntu


Open a new Terminal Window.
Type in the following command:
mysqldump -h localhost -u root -pPASSWORD database > backup.sql
This will backup the database to the file backup.sql
-h = Hostname
-u = Username
-p = Password, no space between the p and the password allowed

NOTE: Has been tested on Ubuntu 9.04 and mySql 5.0.75

How to export a MySql database to a file via the Command Line in Linux


Open a new Terminal Window Type in the following command {codecitation class=”brush: bash;”} mysqldump -uUsername -pPassword DatabaseName > outputFile.sql {/codecitation} The command above will export a selected database to a file called outputFile.sql mysqldump = a database backup program -u = Username for the database -p = Password for the database DatabaseName = The database...

About Author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

Follow Me