Unix Technical Forum

copy table

This is a discussion on copy table within the pgsql Sql forums, part of the PostgreSQL category; --> Hello How can i copy a table from one schema to another.. Example.. * I have a database "mydatabase" ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 11:49 AM
Shavonne Marietta Wijesinghe
 
Posts: n/a
Default copy table

Hello

How can i copy a table from one schema to another..

Example..

* I have a database "mydatabase"
* then i have 2 schemas "myschema1" and "myschema2"
* in "myschema1" i have inserted a new line and i want to copy that to "myschema2" so they both will be same..

How can i do it with SQL ??

I use pgadmin 3 to make my database in postgresql

thank u
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 11:49 AM
A. Kretschmer
 
Posts: n/a
Default Re: copy table

am 14.10.2005, um 10:44:13 +0200 mailte Shavonne Marietta Wijesinghe folgendes:
> Hello
>
> How can i copy a table from one schema to another..


create table as select * from table

>
> Example..


Yeah!

test=# create schema foo;
CREATE SCHEMA
test=# create schema bar;
CREATE SCHEMA
test=# create table foo.test (id int);
CREATE TABLE
test=# insert into foo.test values (1);
INSERT 3381544 1
test=# create table bar.test as select * from foo.test;
SELECT
test=# select * from foo.test;
id
----
1
(1 row)

test=# select * from bar.test;
id
----
1
(1 row)


> I use pgadmin 3 to make my database in postgresql


You shold better use psql to learn sql.


Regards, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47212, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-19-2008, 11:49 AM
Muralidharan Ramakrishnan
 
Posts: n/a
Default Re: copy table

INSERT INTO MYSCHEMA2.TABLENAME
SELECT * FROM MYSCHEMA1.TABLENAME WHERE < CONDITION >

Shavonne Marietta Wijesinghe <shavonne.marietta@studioform.it> wrote:
Hello

How can i copy a table from one schema to another..

Example..

* I have a database "mydatabase"
* then i have 2 schemas "myschema1" and "myschema2"
* in "myschema1" i have inserted a new line and i want to copy that to "myschema2" so they both will be same..

How can i do it with SQL ??

I use pgadmin 3 to make my database in postgresql

thank u



---------------------------------
Yahoo! India Matrimony: Find your partner now.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:34 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com