How To Handle Table Column Named With Reserved Sql Keyword?

前端 未结 3 699
花落未央
花落未央 2020-12-06 16:35

I have an old table that has a column named \"RANK\" and this name is a keyword in Oracle, I don\'t know how this table created and I can\'t rename this column because it is

相关标签:
3条回答
  • 2020-12-06 17:06

    Oracle uses double quotes " to escape reserved words.

    insert into mytbl ("RANK")
    select "RANK" 
    from other_table
    

    One other note, Oracle requires correct case as well.

    0 讨论(0)
  • 2020-12-06 17:11

    In my case, there is , in my query.

    UPDATE SCHEMA.TABLE SET PART_NO = '1S7F530400', WHERE PART_NO = '1S7?F5304?00';
    

    This should be:

    UPDATE SCHEMA.TABLE SET PART_NO = '1S7F530400' WHERE PART_NO = '1S7?F5304?00';
    
    0 讨论(0)
  • 2020-12-06 17:25

    First of all, You shall not use reserved keywords as column name and table name.

    Oracle uses Double quotes " to parse reserved keywords so you can parse the keywords by placing it in doubles quotes "".

    insert into mytbl ("RANK")
    select "RANK" 
    from other_table
    
    0 讨论(0)
提交回复
热议问题