I have two tables:
create table country(
country_code varchar2(2) PRIMARY KEY,
country nvarchar2(57) NOT NULL
);
SQL> desc airport_final
Name Null? Type
----------------------------------------- -------- ----------------------------
IATA_CODE VARCHAR2(3)
CITY_CODE VARCHAR2(3)
CITY_NAME NVARCHAR2(24)
COUNTRY_CODE VARCHAR2(2)
COUNTRY_NAME NVARCHAR2(33)
NO_OF_AIRPORTS NUMBER(1)
AIRPORT_CODE VARCHAR2(3)
CITY_WITH_COUNTRY NVARCHAR2(61)
AIRPORT_NAME NVARCHAR2(80)
When I select uique/distinct country_code then its showing 23 records:
SQL> SELECT distinct(country_code),country_name from airport_final;
230 rows selected.
But when I try to insert these records from airport_final table to country table then:
SQL> INSERT INTO country(country_code,country)
SELECT distinct(country_code),country_name from airport_final; 2
SELECT distinct(country_code),country_name from airport_final
*
ERROR at line 2:
ORA-01400: cannot insert NULL into ("TESTING"."COUNTRY"."COUNTRY")
What should I do?
Best Regards
NOT NULLconstraint onCOUNTRY, soCOUNTRY_NAME(where the data is coming from) must also beNOT NULL.