2

The DB I have is divided in many datasets (shape format, each .zip I send to CartodDB consist of 4 files, .dbf, .prj, .shp, .shx). The problem is that the free account only allows 4 datasets, each one associated to a layer.

To solve this problem I'd like to join all my datasets in just one. All datasets share the same structure (same columns) due to the fact they form part of the same DB. I hope there is a way to add rows from one dataset to another.

  • The free account does not allow just 4 datasets now, we offer unlimited tables for everyone. If you let me know your username I can fix that for you if needed! – iriberri May 5 '15 at 8:37
  • I just checked and you have unlimited datasets in your account. Adding more of them should not be an issue: you should be able to go to Create new dataset or create new map and import files from there. In case you're getting a specific error for that, please let us know at support@cartodb.com to see your specific case :) – iriberri May 6 '15 at 8:14
3

The union all approach will just join the tables in as a "query view". You can use the option "create dataset from query" in order to store all the results in the same dataset.

Another approach would be using INSERTS in order to append your tables (aka: "insert rows from one dataset to another", for example:

-- Insert data from table2 to table1

INSERT INTO table_1 (column1, column2, column3, column4)
    SELECT column1, column2, column3, column4
    FROM table_2

-- Insert data from table3 to table1

INSERT INTO table_1 (column1, column2, column3, column4)
    SELECT column1, column2, column3, column4
    FROM table_3

-- Insert data from table4 to table1

INSERT INTO table_1 (column1, column2, column3, column4)
    SELECT column1, column2, column3, column4
    FROM table_4
1

In the SQL editor, you can use UNION ALL to join tables that have the same columns:

(select * from table_1) UNION ALL (select * from table_2) UNION ALL (select * from table_3)

UNION ALL will not get rid of duplicates, if you have duplicate rows in different tables use UNION instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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