如何在oracle中添加commission_pct列

nwnhqdif  于 2023-02-07  发布在  Oracle
关注(0)|答案(1)|浏览(175)

我手动放置了架构,但是没有commission_pct列,我如何添加它?
我在任何地方都找不到commission_pct数据...
请帮助我:(

select  employee_id as 사원번호,
            first_name || ' ' || last_name as 사원명,
            nvl( salary + (salary * commission_pct), salary)*12 as 연봉,
            department_id as 부서번호
    from employees
    where department_id in(30,50,60) and
        nvl( salary + (salary * commission_pct), salary)*12 >= 20000 and
        nvl( salary + (salary * commission_pct), salary)*12 <= 60000
    order by 부서번호, 연봉 desc;```

ORA-00904:“委员会_PCT”:000000-“%s:不存在无效标识符

mwngjboj

mwngjboj1#

这有点奇怪您应该如何处理不存在列?您确定您连接到了正确的模式并拥有所有应该拥有的表吗?
对于您的问题,您可以使用alter table向表中添加一个新列,具体方法如下:我的employees表是一个虚拟表,它不代表你的表。

SQL> desc employees
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 EMPLOYEE_ID                               NOT NULL NUMBER
 FIRST_NAME                                NOT NULL VARCHAR2(30)
 LAST_NAME                                 NOT NULL VARCHAR2(30)
 HIRE_DATE                                 NOT NULL DATE
 SALARY                                    NOT NULL NUMBER(8,2)

SQL> alter table employees add commision_pct number;

Table altered.

要设置值,update表为

SQL> update employees set commision_pct = 15;

1 row updated.

SQL>

相关问题