Insert Data in a selected columns

Database
Enthusiast

Insert Data in a selected columns

I want to INSERT data in a selected columns of  a Table using FastLoad OR Bteq Process. 

2 REPLIES
Senior Apprentice

Re: Insert Data in a selected columns

Hi,

 

I'm not sure what the real problem is here, but if you want to insert a row and only provide values for some columns in the table definition then you can just name the columns that you are providing values for on the INSERT statement.

 

Assume the table has 5 columns (col1 to col5) and you only want to provide values for col1, col2 and col4. You can code:

INSERT INTO table (col1, col2, col4) 
VALUES(value-for-col1, value-for-col2, value-for-col4);

Does that help?

 

Cheers,

Dave

 

Ward Analytics Ltd - information in motion
www: http://www.ward-analytics.com
Highlighted
Senior Apprentice

Re: Insert Data in a selected columns

Sorry, I should also have said that any columns in the table that you do not provide a value for must be defined as either nullable or they must have a default value.

Dave

Ward Analytics Ltd - information in motion
www: http://www.ward-analytics.com