zoukankan      html  css  js  c++  java
  • 数据库学习之四

    1、左外连接: left join。。。on;右外连接:right join ...on;全外连接:full join....on

    any任意一个值,>any()大于最小的值;<any()小于最大的值;

    >all()大于最大的值;<all()小于最小的值; 

    采用in()函数,用两个字段去匹配分别为:e.division_id,e.salary

    三个表连接的两种方式:

    2、创建表用create table ,添加各个数据类型,用insert into添加数据

    删除表:drop table 。。。

    添加主键:primary  key  如:c_id number(5)primary key,

    数据不为空:not null  如;c_name varchar2(20) not null,

    添加缺省值(默认值)dafault 如: c_date date default date'1990-01-01'

    3、修改字段约束条件

    alter table c modify c_sex varchar2(20)

    on delete cascade :在后面添加此句子删除此表外键时,与其相关表的数据都会被删除

    on delete set null:删除与之相冲突的字段;

    4、重命名表与字段

    alter table xi rename to xi1;

    alter table xi1 rename to xi;

    alter table xi rename column xi_name to xi_n

    alter table xi rename column xi_n to xi_name;

    5、删除表

    Deletedroptruncate 三者的区别

    Delete from emp_new  删除后未提交前可以回滚,删除速度慢

    TRUNCATE TABLE emp_new;  快速的删除表数据,并保留表结构,删除的数据不可以用rollback回滚,不能truncate一个带外键的表

    DROP TABLE emp_new;  删除了表结构以及内容

  • 相关阅读:
    Swagger注解及参数细节的正确书写。
    TCP连接为什么三次握手四次挥手
    OpenMeetings安装
    [LeetCode]Best Time to Buy and Sell Stock III
    [LeetCode]Best Time to Buy and Sell Stock
    [LeetCode]Best Time to Buy and Sell Stock II
    [LeetCode]Delete Node in a Linked List
    [LeetCode]Lowest Common Ancestor of a Binary Search Tree
    [LeetCode]Invert Binary Tree
    [LeetCode]Same Tree
  • 原文地址:https://www.cnblogs.com/melodylin/p/5526415.html
Copyright © 2011-2022 走看看