Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Showing posts with label Postgre. Show all posts
Showing posts with label Postgre. Show all posts

Friday, March 27, 2009

How to copy data from table to another in Postgres

Here is the syntax for the same
Insert into table2 [column1, ...] Select * from table1;

Saturday, January 17, 2009

How to convert varying character type to integer in postgres

When you directly try to use 
alter table alter Type integer you will get exception in postgres.

So Using clause comes to rescue. It basically provides a mean (using a method)to convert the incoming data to appropriate type. So, you can try something as below:

CREATE OR REPLACE FUNCTION charToInt(charParam character varying)
  RETURNS integer AS
$BODY$
SELECT CASE WHEN trim($1) SIMILAR TO '[0-9]+' 
        THEN CAST(trim($1) AS integer) 
    ELSE NULL END;

$BODY$
  LANGUAGE 'sql' IMMUTABLE STRICT;

alter table (table name)
alter (column name of varying char type) TYPE integer  USING charToInt(column name of varying char type );

Friday, November 23, 2007

Installing Postgre on windows vista

There is a frequent problem while installing postgre database on windows vista. like errors reporting unable to create user and rollback of installation.

To avoid this, run the setup program by right click and run as administrator mode.

other way is go to program-> accessories -> command prompt and right click on it and use option run as administrator. now go to the directory where postgre is dump is located and run the setup.