postgresql - SQL NULL in DDL (Data Definition Language) -
i imported datas .txt file database via postgresql. problem is, columns of movies empty. e.g there no rating film "abcd" , when importing via copy
postgresql throws error "no data in column". how can catch error in create table
order. tried "null", not work either.
create table movies ( imdib varchar not null, name varchar not null, year integer null, rating float null , votes integer null , runtime varchar null , directors varchar null , actors varchar null , genres varchar null ); copy movies 'c:\users\max\desktop\imdb_top100t.txt' delimiter e'\t' ;
error message:
error: missing data column „year“ context: copy movies, line 3060: „tt0283003 “ ********** error ********** error: missing data column „year“ sql status:22p04 context: copy movies, line 3060: „tt0283003 “
edit: on line 3060
tt0081590 sällskapsresan eller finns det svenskt kaffe på grisfesten 1980 7.3 4477 107 mins. lasse à berg|peter hald lasse à berg|lottie ejebrant|jon skolmen comedy
**edit 2: think problem "Ã" postgresql can not recognize letter **
null in default copy format expressed \n
can seen with:
copy (select null) stdout;
result:
\n
but if you're copy'ing file has not been exported postgres copy file, there's no reason use postgres format backslash escape sequences.
generally, it's csv format used tabular-style data, , needs turned on explicitly option copy, in:
copy tablename 'filename.txt' (delimiter e'\t', format csv, null '');
null can distinguished empty strings if necessary using force_quote
, force_not_null
options.
Comments
Post a Comment