Database System Concepts (2) -- SQL

来源:互联网 发布:淘宝上有正宗沉香卖吗 编辑:程序博客网 时间:2024/05/06 17:56
 SQL stand for Structrue Query Language including:
    Data-definition language (DDL): commands for defining relation schemas, deleting relations, and modifying relation schemas
    Interactive data -manipulation language (DML): a query language based on both the relational algebra and the typle relational calculus
    View definition: commands for defining views
    Transaction control: commands for specifying the beginning and ending of transactions
    Embedded SQL and dynamic SQL: can be embedded within programming languages
    Integrity: commands for specifying integrity constraints that the data stored in the database must satisfy
    Authorization: commands for specifying access rights to relations and views

    Clauses
    DML:
        select
        from
        where
       as: 1 rename operation, 2 derived relations
       distinct
       like: Percent(%) matches any substring, Underscore(_) matches any character
       order by: desc, asc
       union, union all(retain all duplicates)
       intersect, intersect all(retain all duplicates, the number of duplicates that appear in the result is equal to the minimum number of duplicates in both table)
       except, except all
       avg, min, max, sum, count
       group by
       having
       is null, not null
       exists, not exists
       unique, not unique
       with: define a temporary view
          with max-balance(value) as
             select max(balance)
             from account
          select .....
          from max-balance......
       delete
       insert into table-name values or <select clause>
       update table-name set
       case:
          case
             when pred1 then result1
             when pred1 then result2
          end
       inner join...on, natural inner join
          table1 inner join table2 on attribute
       (natural) (full, left, right) outer join...(on)

    DDL
       create table
       drop table
       alter table... add(drop)
       not null
       primary key
       create view name as <query expression>, drop view
原创粉丝点击