Skip to content

G-3110: Always specify the target columns when coding an insert statement.

Major

Maintainability, Reliability

Reason

Data structures often change. Having the target columns in your insert statements will lead to change-resistant code.

Example (bad)

1
2
3
4
5
insert into departments
     values (departments_seq.nextval
            ,'Support'
            ,100
            ,10);

Example (good)

1
2
3
4
5
6
7
8
insert into departments (department_id 
                        ,department_name
                        ,manager_id
                        ,location_id)
     values (departments_seq.nextval
            ,'Support'
            ,100
            ,10);