import file with variable columns into DB

neegotiator

Golden Member
Jan 19, 2006
1,117
1
0
I don't have experience with many DB's, so apologies if this is an obvious question.

Just learned that SQL Server allows importing files with variable columns into a table. So if table exists with 5 columns, then

Col1, Col2, Col3, Col4, Col5
aaa,bbb,ccc,ddd,eee
111,222,333
fff,ggg,hhh,iii,jjj

is imported as

Col1, Col2, Col3, Col4, Col5
aaa,bbb,ccc,ddd,eee
111,222,333, NULL, NULL
fff,ggg,hhh,iii,jjj


Teradata doesn't allow this, and I could be wrong but I don't THINK Oracle allows this. Is this common among other DB's? Just seems odd to allow this, I'd imagine different number of columns in a record usually means a data issue, can't really make an assumption whether missing columns were from beg/mid/end.
 

beginner99

Diamond Member
Jun 2, 2009
5,320
1,768
136
That has more to do with the import tool you use and less with the database.

If you have a normal csv like this

Col1, Col2, Col3, Col4, Col5
aaa,bbb,ccc,ddd,eee
111,222,333,,
fff,,hhh,iii,jjj

any non-retarded import tool will import the empty values as NULL assuming that column is nullable.

And if a tool works without the commas at the end, well I would consider that a feature.