Search code examples
cassandracqlcqlsh

InvalidRequest: code=2200 [Invalid query] message="Unknown identifier emp_id"


I have created the keyspace and created the table inside it emp, its giving me error while inserting values, have I missed anything?

cqlsh> create keyspace dev WITH replication = {'class': 'SimpleStrategy','replication_factor':1}; cqlsh> use dev ... ; cqlsh:dev> create table emp(empid int primary key,emp_first varchar,emp_last varchar,emp_dept varchar); cqlsh:dev> select * from emp

cqlsh:dev> insert into emp(emp_id,emp_first,emp_last,emp_dept) values(1,'fred','smith','eng'); InvalidRequest: code=2200 [Invalid query] message="Unknown identifier emp_id"


Solution

  • In your CREATE TABLE statement, you called it empid

    In your INSERT statement, you called it emp_id.

    Simply change emp_id in your INSERT statement to empid

    INSERT INTO dev.emp (empid,emp_first,emp_last,emp_dept) values(1,'fred','smith','eng');