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是对于每一行来说的



  • 相关阅读:
    Python操作 RabbitMQ、Redis、Memcache、SQLAlchemy
    Twsited异步网络框架
    MySQL-python模块
    python3安装Fabric模块
    PInvoke.net Visual Studio Extension
    资源下载站
    WPF RTSP存储到一个文件中的位置
    Windows 7 中未能从程序集System.ServiceModel
    无法在WEB服务器上启动调试,Web 服务器配置不正确
    CS0016: 未能写入输出文件“c:WINDOWSMicrosoft.NETFramework.。。”--“拒绝访问
  • 原文地址:https://www.cnblogs.com/cdyboke/p/7159711.html
Copyright © 2011-2022 走看看