Is there a MySQL equivalent of SHOW CREATE TABLE in postgres? Is this possible? If not what is the next best solution?

I need the statement because I use it to create the table on an remote server (over WCF).

link|improve this question
feedback

2 Answers

up vote 2 down vote accepted

You can try to trace in the PostgreSQL log file what "pg_dump -t table -s" really does.Then you can use the same method to write your own sql function.

link|improve this answer
ok, i traced the pg_dump. But it wasn't as easy, becouse i had to write my own function in C# to write the create table statement. But it was a big help, so thank you veeeeerrrryyyy much. :D – vlebar Feb 9 '11 at 7:41
feedback

pg_dump:

pg_dump --schema-only -t tablename

or use PostgreSQL GUI Tools(pgAdmin,phpPgAdmin,etc.)

link|improve this answer
i'll try to explain the problem in more detail. I need the sql statement (select or stored procedure) becouse I execute the sql command in C# (NpgsqlCommand). So I think the pg_dump is not the solution in this case. :( – vlebar Feb 6 '11 at 22:00
Why not? --schema-only has this exact purpose: Show the SQL statements to create the schema/table. You can than feed this output into your C# program somehow. – SvenW Feb 6 '11 at 22:10
look at the information_schema views: postgresql.org/docs/9.0/interactive/information-schema.html – alvosu Feb 6 '11 at 22:12
1  
@SvenW: I would do that if i'd have a known set of tables. The problem is that the user can, if he chooses to, sync any table in selected database and then create the selected table on a remote server behind a wcf service. I can do that with mssql and now i want to expand the client program to other sql servers (mysql, oracle, postgresql, ...) OK, I can do pg_dump for a table that the user wants to sync, but if it is at all possible to do that just in plsql, i want to do it in plsql – vlebar Feb 6 '11 at 22:36
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.