d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Database Question
Add Reply New Topic New Poll
Member
Posts: 8,635
Joined: Dec 28 2007
Gold: 87.00
May 19 2012 12:49am
Not really a java problem, but there is no database section so posting it here.

I have an existin database and table that contains information (20 columns), colums that matter are ID(int) and check(boolean). I have csv file that has the ID(int) and check value(0 or 1), I would like to import my csv file check values to my tables check(boolean) column. How can I do this in odb(LibreOffice)?

Thanks.
Member
Posts: 8,635
Joined: Dec 28 2007
Gold: 87.00
May 19 2012 01:48am
Solved this by first taking the table to spreadsheet and then importing the csv there and after combining the data took the spreadsheet back to database. Is there any better way to do this?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 19 2012 03:33pm
im not familiar with LibreOffice. in general, i try these 3 (in order of preference):

1. use an import button in the DBMS, probably for a CSV file. SQL Developer and SQL Server both have it.
2. Turn it into an excel sheet and add a new column, something like INSERT INTO TABLE (col1, col2, ..) VALUES (A1, B1, C1, ...). after you write the first query, drop it down to copy the formula across all rows. then copy/paste that column into your DBMS and execute
3. write a program to do it via odbc/jdbc/etc

/edit: or are you asking specifically how to update just that one column? if that's the case, modify #1 which is essentially your method. you could also modify #2 to use UPDATE. or you can create a new table and import it, then run a simple update query:

UPDATE OT
SET VALUE=NT.VALUE
FROM OLD_TABLE OT
JOIN NEW_TABLE NT ON NT.ID=OT.ID

This post was edited by carteblanche on May 19 2012 03:37pm
Member
Posts: 8,635
Joined: Dec 28 2007
Gold: 87.00
May 21 2012 01:04pm
Quote (carteblanche @ 19 May 2012 23:33)
im not familiar with LibreOffice. in general, i try these 3 (in order of preference):

1. use an import button in the DBMS, probably for a CSV file. SQL Developer and SQL Server both have it.
2. Turn it into an excel sheet and add a new column, something like INSERT INTO TABLE (col1, col2, ..) VALUES (A1, B1, C1, ...). after you write the first query, drop it down to copy the formula across all rows. then copy/paste that column into your DBMS and execute
3. write a program to do it via odbc/jdbc/etc

/edit: or are you asking specifically how to update just that one column? if that's the case, modify #1 which is essentially your method. you could also modify #2 to use UPDATE. or you can create a new table and import it, then run a simple update query:

UPDATE OT
SET VALUE=NT.VALUE
FROM OLD_TABLE OT
JOIN NEW_TABLE NT ON NT.ID=OT.ID


Was looking for build in import for existing table, but seems like there is no such thing. You can only create new table with import option, not add data to existing table.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll