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.

0

1 Answer 1

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';
Sign up to request clarification or add additional context in comments.

3 Comments

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.