I have to insert in the table students all the values of the table ALUMNADO_NUEVO. But I want all the students I insert to have the cod_course = 1. I leave the table schema in the figure. I have tried the following:
Insert into alumnado (nombre,apellidos,sexo,fecha_nac,cod_curso)
values (select ((nombre,apellidos,sexo,fecha_nac) from alumnado_nuevo, 1)
Insert into alumnado (nombre,apellidos,sexo,fecha_nac,cod_curso)
values (select * from alumnado_nuevo, 1)
both return the same error
Bug Report - SQL Error: ORA-00936: Missing expression 00936.00000 - "missing expression"
The syntax of
insert
/select
does not go through using the clausevalues
, but is of the form:The number of fields in both lists must be the same and the data types of the select must be compatible with the data type of the destination column. I say compatible in the sense that it must be the same data type, or one that has an automatic conversion to the target data type.
Adapting this to your case, you could do something like:
You notice that the statement
select
, in addition to the fields of the source table, has a column with the constant value1
, which is the one that will remain in the columncod_curso
of the destination table.