Here is the table:
CREATE TABLE FAMILY (Now if I want to insert values from another table here is the query I used:
ID INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
DESCRIPTION VARCHAR(50) NOT NULL
)
INSERT INTO FAMILY (DESCRIPTION) ( SELECT DISTINCT FAMILY FROM EQUIPMENT_GROUP WHERE FAMILY IS NOT NULL)Please note that I did not put anything into the ID column. If I try to specify a value, it will result in an exception
Since the column has been marked as GENERATED ALWAYS, it handles incrementing the key and assigning it.Exception: Attempt to modify an identity column 'ID'.
0 comments :
Post a Comment