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.
1 Answer
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';
3 Comments
user1235288
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
hmm ok thx, is it also possible to merge two identical schema with identical table names?
A.H.
No. You have to rename the tables first.
ALTER TABLE old RENAME TO new; will do this.