Oracle

  1.  数据库连接
    # 需要设置这个不然插入中文会乱码
    os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
    db = cx_Oracle.connect('name/pass@ip:1521/helowin')
    cursor=db.cursor()
    cursor.execute(sql)
    db.commit()
    cursor.close()
    db.close()
  2.   rownum
    用于从查询返回的行的编号,返回的第一行分配的是1,第二行是2,依此类推,这个伪字段可以用于限制查询返回的总行数,
    而且rownum不能以任何表的名称作为前缀,注意子查询中的rownum必须要有别名

    查询从第二行记录以后的记录,从所有查到的里面取伪字段行号大于2的数据
    select * from(select rownum no ,id,name from student) where no>2;

    https://www.jb51.net/article/65960.htm
  3. 判断大于某个时间
    字符串转时间
    to_date('2005-01-01 13:14:20','yyyy-MM-dd HH24:mi:ss')

    https://blog.csdn.net/idomyway/article/details/78785112
  4.  插入自动填充时间
    直接写 sysdate 就可以
    cursor.execute("insert into px_jobtype (id, name, classify_id,create_user_id,create_user_name,create_time) 
       values (‘{}‘, ‘{}‘, ‘{}‘, ‘{}‘, ‘{}‘,sysdate)
    ".format(id2,name2,result,"admin","超级管理员")) conn.commit();
原文地址:https://www.cnblogs.com/luochunxi/p/15215728.html