zoukankan      html  css  js  c++  java
  • 20170802上课随笔

    deptno int constraint emp_deptno_fk references dept(deptno))级联约束

        deptno int constraint emp_deptno_fk references dept(deptno) on delete set null)或者on delete cascade//级联删除

    ALTER TABLE test_phone_tab disable constraint test_phone_pk; //禁用约束

    ALTER TABLE test_phone_tab enable constraint test_phone_pk; //启用约束

    序列:

    SQL> create sequence test_seq increment by 1 start with 1 maxvalue 1000 nocycle cache 20;

    SQL> create table t1(x int primary key, y int);

    SQL> insert into t1 values (test_seq.nextval, 11);       反复执行

    SQL> select * from t1;

     

    索引:

    主键和唯一性约束自动创建索引:

    SQL> select constraint_name, constraint_type from user_constraints where table_name='EMPLOYEES';

    SQL> select index_name, index_type from user_indexes where table_name='EMPLOYEES';

    SQL> set autot on

    SQL> select last_name from employees where employee_id=100;   走索引

    SQL> select email from employees;                                               走索引

    SQL> select last_name from employees where salary=2100;              全表扫描

    SQL> create index emp_salary_ix on employees(salary);

    SQL> select last_name from employees where salary=2100;              走索引

    SQL> set autot off

  • 相关阅读:
    UVa 116 单向TSP(多段图最短路)
    POJ 1328 Radar Installation(贪心)
    POJ 1260 Pearls
    POJ 1836 Alignment
    POJ 3267 The Cow Lexicon
    UVa 1620 懒惰的苏珊(逆序数)
    POJ 1018 Communication System(DP)
    UVa 1347 旅行
    UVa 437 巴比伦塔
    UVa 1025 城市里的间谍
  • 原文地址:https://www.cnblogs.com/guoxf/p/7277805.html
Copyright © 2011-2022 走看看