Loading data into column with default as nextval(seq)
I would like to know if its possible to use the COPY statement to load data into a table that has a column with a default value setup as nextval(seq). Ex: table (i int default nextval('seq_name'), j int, k varchar) I would like to insert data into this table using the copy statement. An example file could be 1, 'syz' 2, 'abc' 3, 'ert' So at the end I would want data in the table to be like 1,1,'syz' 2,2,'abc' 3,3'ert' And No, I don't want to use identity for this case. It has to be a sequence. Does copy allow you to to do this? Also, is there a way to call the nextval funciton from within the copy statement?
0
Comments
You can follow any of two approaches:
Firs Approach: Use nextval function in COPY command
Creating Table: Creating Sequence: Using COPY: Checking Records: Second Approach : Using default value as nextval in table column
Creating sequence: Creating table: Using COPY: Checking Records:
Hope this helps.