zoukankan      html  css  js  c++  java
  • insert 插入

    insert

    
    
    [ WITH [ RECURSIVE ] with_query [, ...] ]
    INSERT INTO table_name [ AS alias ] [ ( column_name [, ...] ) ]
        { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query }
        [ ON CONFLICT [ conflict_target ] conflict_action ]
        [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]
    
    where conflict_target can be one of:
    
        ( { index_column_name | ( index_expression ) } [ COLLATE collation ] [ opclass ] [, ...] ) [ WHERE index_predicate ]
        ON CONSTRAINT constraint_name
    
    and conflict_action is one of:
    
        DO NOTHING
        DO UPDATE SET { column_name = { expression | DEFAULT } |
                        ( column_name [, ...] ) = ( { expression | DEFAULT } [, ...] ) |
                        ( column_name [, ...] ) = ( sub-SELECT )
                      } [, ...]
                  [ WHERE condition ]

    test=> insert into ask(id,publisherID,reward,cost,rangee,typee,label,content,image,createTime,zan,school,college) values
    test-> (1,1,4,10,'school','急问','学习','这道题怎么做','{"/icon/default.ico"}',now(),1,'广州大学',null),
    test-> (2,2,10,10,'school','急问','实习','xxx公司怎样','{"/icon/default.ico"}',now(),2,'广州大学',null),
    test-> (3,3,100,10,'college','急问','美食','xxx好不好吃','{"/icon/default.ico"}',now(),3,'广州大学','计算机科学与教育软件学院'),
    test-> (4,4,200,10,'college','急问','其它','xxx怎么去','{"/icon/default.ico"}',now(),4,'广州大学','计算机科学与教育软件学院'),
    test-> (5,3,100,10,'college','急问','美食','xxx好不好吃','{"/icon/default.ico"}',now(),5,'广州大学','人文学院'),
    test-> (6,4,200,10,'college','急问','其它','xxx怎么去','{"/icon/default.ico"}',now(),6,'广州大学','人文学院') on conflict do nothing;
    INSERT 0 4

    这里的on conflict是对于每一行来说的



  • 相关阅读:
    [抄书]The Pipes and Filters pattern
    [抄书]The Layers pattern
    OpenGL Step by Step (1)
    [HOOPS]二维点向三维空间投影
    心仪已久的工具:BoundsChecker v7.2
    [HOOPS]用HC_Show_...获取正确的点的坐标位置
    小试zlib
    XML (2) Document Type Definitions (DTD)
    UML (1) 设计模式及作业附图
    XML (1) 什么是XML
  • 原文地址:https://www.cnblogs.com/cdyboke/p/7159711.html
Copyright © 2011-2022 走看看