1

I've got some data from one year but it is split into two schema. How can I put them together in one schema so that I can process it with MATLAB.

Cœur
  • 37,241
  • 25
  • 195
  • 267
user1235288
  • 75
  • 1
  • 2
  • 6

1 Answers1

2

If your table names in both schemas are unique you can use in the psql shell

ALTER TABLE old_schema.table_name SET SCHEMA new_Schema;

On the other hand I would be surprised when Matlab did not allow you to access any schema. Did you try to access your tables with old_schema.table1 and new_schema.table2? In that case you wouldn't have to change the database.

Edit

If you have quite a handful tables, you have to issue the above command for each table. There is no way around this. But a little help: You can compute the commands and execute the results by hand. Computation is done with this:

select 'ALTER TABLE '||table_schema||'.'||table_name||' SET SCHEMA new_schema' 
   from information_schema.tables 
   where table_type = 'BASE TABLE' and table_schema = 'old_schema';
A.H.
  • 63,967
  • 15
  • 92
  • 126
  • ok this works with one table but I got 28 and would like to do it by SQL code. Yes matlab can do that but I need one shema because my GUI construction leads me no other choice. – user1235288 Feb 27 '12 at 13:23
  • hmm ok thx, is it also possible to merge two identical schema with identical table names? – user1235288 Feb 27 '12 at 13:54
  • No. You have to rename the tables first. `ALTER TABLE old RENAME TO new;` will do this. – A.H. Feb 27 '12 at 14:01