employees 表
employee_id  number not null,primary key
emp_name     varchar(30)
mgr_id       number Reference employee_id  column 
 number Reference employee_id  column 怎么解释呢??谢谢

解决方案 »

  1.   


    create table emp3 (employee_id number primary key,
    emp_name varchar2(30),
    mgr_id number references emp3(employee_id));insert into emp3 values(1, 'Adom', null);
    1 row created.
    insert into emp3 values(2, 'Bob', 1);
    1 row created.
    insert into emp3 values(3, 'Cindy', 3);
    1 row created.
    insert into emp3 values(4, 'Dog', 5);
    ORA-02291: integrity constraint (HR.SYS_C0019505) violated - parent key not found
    insert into emp3 values(4, 'Dog', 4);
    1 row created.
      

  2.   

    mgr_id number references emp3(employee_id));
    这个语句怎么解释呢?谢谢
      

  3.   

    mgr_id number references emp3(employee_id)
    意思是说,mgr_id引用自己表的employee_id字段的值,可以为null,但如果不为null时,其值必须在employee_id中找到,否则报ORA-02291: integrity constraint (...) violated - parent key not found
      

  4.   

    mgr_id引用自己表的employee_id字段的值???
      

  5.   

    insert into emp3 values(1, 'Adom', null);
    1 row created.
    insert into emp3 values(2, 'Bob', 1);
    1 row created.
    insert into emp3 values(3, 'm', 2);
    1 row created.
    insert into emp3 values(2, 'b', 3);
    1 row created.  只允许这样的数据才能插入成功
      

  6.   

    一般这样创建表有什么实际的意义么?thanks  a l ot  以前没有接触哦 最近在考试题目中发现的哦
      

  7.   

    yes, 比如说,你上司的employee_id是1,那么你的mgr_id就应该是1。Oracle允许你的mgr_id为null,这样你就没有上司。如果你的mgr_id是99,但是表中没有一条记录的employee_id是99,那么Oracle就告诉你违反了完整性约束。
      

  8.   

    还有创建synonym是怎么回事呢? view方面的
      

  9.   

    同名(synonym)这方面我也没有多少研究。
    你英语好的话可以看看Oracle的官方文档:
    A synonym is an alias for any table, view, materialized view, sequence, procedure, function, package, type, Java class schema object, user-defined object type, or another synonym. Because a synonym is simply an alias, it requires no storage other than its definition in the data dictionary.Synonyms are often used for security and convenience. For example, they can do the following:•Mask the name and owner of an object•Provide location transparency for remote objects of a distributed database•Simplify SQL statements for database users•Enable restricted access similar to specialized views when exercising fine-grained access controlhttp://download.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#CNCPT711
      

  10.   

    还有数据库中的role和privilege都有啥用呢??这个也不敢在用到的数据库中进行测试0 大家有用过的么?
    看文档看不大懂