有以下几种情况
1. 查询的表的表名 是关键字
2. 查询的列名 是关键字
3. 表明是关键字的表,字段怎么通过代码去重命名知道的请帮帮忙,谢谢!

解决方案 »

  1.   


    scott@YPCOST> create table sum(
      2  id number,
      3  count number);表已创建。scott@YPCOST> select * from sum;未选定行scott@YPCOST> insert into sum values(23,33);已创建 1 行。scott@YPCOST> insert into sum values(234,33);已创建 1 行。scott@YPCOST> select * from sum;        ID      COUNT
    ---------- ----------
            23         33
           234         33scott@YPCOST> select count from sum;     COUNT
    ----------
            33
            33scott@YPCOST> select distinct count from sum;     COUNT
    ----------
            33
      

  2.   

    select * from v$reserved_words
    如果是表,删除,重建
    如果是字段alter table tablename rename column tt to pp
      

  3.   

    当然这个肯定是不好的
    最后还是修改表名和列名
    scott@YPCOST> alter table sum rename to t_sum;表已更改。scott@YPCOST> alter table t_sum rename column count to c_count;表已更改。scott@YPCOST> select * from t_sum;        ID    C_COUNT
    ---------- ----------
            23         33
           234         33
      

  4.   


    --修改表名
    alter table table1 rename to tab1;--修改列名
    ALTER TABLE tab1 RENAME COLUMN u_id TO USERID--修改列大小
    alter table table3 modify x varchar2(10);--修改列内容
    update table3 set x='x2' where y = 'Y2'--删除记录
    delete from table3 where x = 'X3'
      

  5.   

    有些关键字是你想用也用不了的
    SQL> create table table (a number);
     
    create table table (a number)
     
    ORA-00903: 表名无效
     
    SQL> 
      

  6.   

    SQL> create table "TABLE" (a number);
     
    Table created
     
    SQL> drop table table;
     
    drop table table
     
    ORA-00903: 表名无效
     
    SQL> drop table "TABLE";
     
    Table dropped
     
    SQL> 
      

  7.   

    rename oldtb to newtb  --改表名--字段alter table tb rename column oldcol to newcol
      

  8.   

    谢谢 表名带关键字这样子修改是可行的
     alter table sum rename to t_sum;
      

  9.   


    这样子不行,应为我的表是在另一个表空间下的
    rename oldtb to newtb 他会报出找不到oldtb 表定义
    但如果带上用户名
    rename userNmae.oldtb to newtb 就有ORA-01765的错使用
    alter userNmae。table sum rename to t_sum;是可以的