使用WITH和AND的Postgresql复制命令错误

时间:2014-08-04 21:34:10

标签: postgresql csv

我有以下命令,我试图将csv复制到postgre表中。

copy "SIS_student"(
            student_id, user_id, peims_id, district_id, prior_identifier, 
            first_name, middle_name, last_name, sex_code, race, date_of_birth, 
            birth_place, country_entry_date, address1, address2, address3, 
            city, state, zip, phone, email, status, campus_id_id, homeroom, 
            eco_dis_code, title1_pa_code, average_daily_attendance, ca_tech_ed_code, 
            bilingual_code, lep_code, esl_code, special_ed_code, gifted_tal_code, 
            at_risk_code, migrant_code, certification_date, graduation_date, 
            quartile, graduation_plan, class_rank, class_size, ranking_date, 
            gpa, nga, weighed_gpa, weighed_nga, peims_campus, next_yr_loc, 
            sumr_loc, c504, avid, last_update_date, last_updated_by, ethnicity_code, grade, 
            homeless, sept1_age, parental_permission, yrs_us_schools_text, 
            achievement_test_date, read_nce1, lang_nce1, eng_prof_test_date, 
            eng_prof_score, eng_prof_score_lvl, sp_prof_test_date, sp_prof_score, 
            sp_prof_score_lvl, peims_language, immigrant, date_entered_us_school, 
            grade_entered, years_in_us_schools, original_placement_date, 
            last_exit_date, parent_perm_date, ethnicity_race_code)
from '/home/abhishek/Downloads/HP/Student.csv' with delimiter ';' and NULL as 'NULL';

但我在AND处收到语法错误。我哪里错了?我这样做的目的是因为即使我启用了NULL值,我的DateTime字段也没有从csv中获取NULL值

1 个答案:

答案 0 :(得分:1)

没有and。这只是一个逗号

with (delimiter ';', NULL 'NULL');

http://www.postgresql.org/docs/current/static/sql-copy.html