How can I translate this 2 queries in postgresql ? :
CREATE TABLE `example` (
`id` int(10) unsigned NOT NULL auto_increment,
`from` varchar(255) NOT NULL default '0',
`message` text NOT NULL,
`lastactivity` timestamp NULL default '0000-00-00 00:00:00',
`read` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `from` (`from`)
) DEFAULT CHARSET=utf8;
Query:
SELECT *
FROM table_1
LEFT OUTER JOIN table_2 ON ( table_1.id = table_2.id )
WHERE (table_1.lastactivity > NOW()-100);
Use:
CURRENT_TIMESTAMP is ANSI standard, and works on Oracle, MySQL, Postgres, SQL Server…
Here’s the CREATE table statement converted:
I can’t find anything about Postgres allowing character sets per table, only that you would set UTF8 support using the UNICODE keyword when creating the database:
Postgre, like Oracle, uses sequences for AUTO_INCREMENT behavior:
Then, you need to call NEXTVAL([your sequence name]) in the insert statement to populate the primary key: