zoukankan      html  css  js  c++  java
  • oracle见表

    1.默认是用当前时间

    create table test
    (id int,
    time date default sysdate);

    2.自动生成guid

     Oracle8i引入了SYS_GUID这个概念,它同Oracle管理员所使用的传统的序列(sequence)相比具有诸多优势。一个序列生成器只是简单地创建从给定的起点开始的一系列整数值,而且它被用在选择陈述式的时候自动地递增该系列。 

    -根据数据库设计说明书创建表
    --GOODS
    create table goods1
    (
    gid number(11) primary key,
    gname varchar2(20) not null unique,
    gprice number(18,1) not null,
    gnum number(11) not null
    );
    
    
    --实现GOODS1表中主键自动生成(需要使用序列和触发器)
    --为GOODS1表创建序列:生成唯一一系列的数
    create sequence goods_seq
    start with 1     --从1开始
    increment by 1  --每次增1
    minvalue 1      --最小值
    maxvalue 999999999999999   --最大值
    nocycle           --不循环取数
    cache 10;       --缓存
    
    
    --为GOODS1表创建触发器,用于自动从序列取值给GOODS1表中GID赋值
    create trigger goods_trigger
    before insert on goods1         --触发条件:在向GOODS1表中插入数据之前自动触发此触发器
    for each row                    --行级触发器:插入的每一行数据都会触发
    begin
       select goods_seq.nextval into :NEW.GID from dual;
    end;
    
    
    
    --向GOODS1表中插入测试数据
    INSERT INTO goods1(gname,gprice,gnum) VALUES('computer',3000,100);
    INSERT INTO goods1(gname,gprice,gnum) VALUES('computer2',3500,100);
    INSERT INTO goods1(gname,gprice,gnum) VALUES('iphone6',4000,200);
    INSERT INTO goods1(gname,gprice,gnum) VALUES('iphone6s',5000,300);
    commit;
  • 相关阅读:
    调用外部 DLL 中的函数(显示调用)
    模式窗体与非模式窗体
    使用PChar和string类型时的内存分配技术
    保密卡程序的编写
    Dll 使用 PChar 参数的小例子
    delphi动态创建组件的颜色
    Dll 模式窗口与非模式窗口
    调用外部 DLL 中的函数(隐式调用)
    内核读写只读内存方法总结[Delphi描述][转帖]
    delphi资源文件制作及使用详解
  • 原文地址:https://www.cnblogs.com/zyzg/p/7845258.html
Copyright © 2011-2022 走看看