<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    JAVA歷程
    希望我的這個博客能給那些想在java的海洋中拼搏的人有所幫助。謝謝光臨!
    posts - 8,  comments - 6,  trackbacks - 0

    1.登陸系統用戶
    sqlplus 然后輸入系統用戶名和密碼
    登陸別的用戶
    conn 用戶名/密碼;
    2.創建表空間
    create tablespace 空間名
    datafile 'c:\空間名' size 15M  --表空間的存放路徑,初始值為15M
    autoExtend on next 10M  --空間的自動增長的值是10M
    permanent online;  --永久使用
    3.創建用戶
    create user shi   --創建用戶名為shi
    identified by scj  --創建密碼為scj
    default tablespace 表空間名 --默認表空間名
    temporary tablespace temp --臨時表空間為temp
    profile default   --受profile文件的限制
    quota unlimited on 表空間名; --在表空間下面建表不受限制
    4.創建角色
    create role 角色名 identified by 密碼;
    5.給角色授權
    grant create session to 角色名;--給角色授予創建會話的權限
    grant 角色名 to 用戶名; --把角色授予用戶
    6.給用戶授予權限
    grant create session,resource to shi;--給shi用戶授予所有權限
    grant create table to shi; --給shi用戶授予創建表的權限
    7.select table_name from user_tables;   察看當前用戶下的所有表
    8.select tablespace_name from user_tablespaces; 察看當前用戶下的 表空間
    9.select username from dba_users;察看所有用戶名稱命令 必須用sys as sysdba登陸
    10.創建表
    create table 表名
    (
    id int not null,
    name varchar2(20) not null
    )tablespace 表空間名  --所屬的表空間
    storage
    (
       initial 64K   --表的初始值
       minextents 1   --最小擴展值
       maxextents unlimited  --最大擴展值
    );
    11.--為usrs表添加主鍵和索引
    alter table users
    add constraint pk primary key (ID);
    12.為已經創建users表添加外鍵
    alter table users
      add constraint fk_roleid foreign key (roleid)
      references role(role_id) on delete cascad; --下邊寫主表的列
       on delete cascad是創建級聯
    13.把兩個列連接起來
    select concat(name,id) from 表名;  --把name和id連接起來
    14.截取字符串
    select column(name,'李') from 表名;  --把name中的‘李’去掉
    15.運行事務之前必須寫
    set serveroutput on;  --打開輸入輸出(不寫的話,打印不出信息)
    16.while的應用
    declare   --聲明部分
    ccc number:=1;  --復職
    a number:=0;
    begin   --事務的開始
    while ccc<=100 loop --循環
    if((ccc mod 3)=0) then --條件
     dbms_output.put_line(ccc||',');    --打印顯示
     a:=a+ccc;
    end if;   --結束if
    ccc:=ccc+1;
    end loop;  --結束循環
    dbms_output.put_line(a); 
    end;   --結束事務
    /   
    17.select into  的用法 --只能處理一行結果集
    declare
      name varchar(30);
    begin
     select username into name
     from users
     where id=2;
    dbms_output.put_line('姓名為:'||name);
    end;
    /
    18.利用%rowtype屬性可以在運行時方便的聲明記錄變量和其他結構
    Set serveroutput on;
    Declare
       utype users%rowtype;
    Begin
    Select * into utype from users where id=20;
    Dbms_output.put_line('姓名'|| utype.username);
    Dbms_output.put_line('生日'|| utype.brithday);
    end;
    /   --%rowtype想當于復制一個表
    19.游標的定義和使用
    Declare
    Cursor ucur is select * from users; --聲明游標
    Us users%rowtype;--定義與游標想匹配的變量
    Begin
    Open ucur;--打開游標
    Fetch ucur into us;
    While ucur %found loop --使用循環遍歷游標的查詢結果
    Dbms_output.put_line('姓名:'||us.username||'生日'||us.brithday);
    Fetch ucur into us;
    End loop;
    Close ucur; --關閉游標
    End;
    20.插入值時,sql語句里取得系統的當前時間用 sysdate

    =======================================
    %found在前一條的fetch語句至少對應數據庫的一行時,%found屬性值為true,否則為false;
    % notfound 在前一條fetch語句沒有對應的數據庫行時,%notfound屬性值為true,否則為false;
    %isopen 在游標打開時%isopen屬性值為true;否則為false;
    %rowcount顯示迄今為止從顯示游標中取出的行數

    20.
    刪除
    drop tablespace 空間名 including contents; --刪除表空間和里面的內容
    drop table 表名   --刪除表
    drop user 用戶名  --刪除用戶

     

    posted on 2007-09-18 18:26 I LOVE JAVA 閱讀(241) 評論(0)  編輯  收藏 所屬分類: Jdbc、Jdo、Database方面

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(1)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 久久国产免费观看精品3| 国产成人精品免费大全| 亚洲国产成人久久77| 亚洲免费黄色网址| 成人免费黄色网址| 小小影视日本动漫观看免费| 国产亚洲?V无码?V男人的天堂| 亚洲国产精品一区二区成人片国内| 久久久无码精品亚洲日韩京东传媒| 亚洲欧美黑人猛交群| 最近中文字幕大全免费版在线| 99在线视频免费观看视频| 亚洲国产精品成人| 亚洲最大黄色网址| 日本一道本不卡免费 | 精品国产污污免费网站入口| 日韩免费高清大片在线| 国产一区二区三区免费在线观看| 久久亚洲精品国产精品黑人| 亚洲乱码中文字幕在线| 国产成人免费福利网站| 亚洲国产精品午夜电影| 扒开双腿猛进入爽爽免费视频| 亚洲AV永久无码精品水牛影视| 四虎精品免费永久免费视频| 日日麻批免费40分钟日本的| 狠狠色香婷婷久久亚洲精品| 在线免费观看伊人三级电影| 免费a级毛片在线观看| 33333在线亚洲| 四虎永久免费地址在线观看| 免费无码又爽又刺激一高潮| 亚洲伊人久久大香线焦| 国产一级淫片免费播放电影| 成人久久免费网站| 中文字幕亚洲精品无码| 色播精品免费小视频| 午夜在线免费视频| 亚洲国产夜色在线观看| 免费人成在线观看网站视频 | 亚洲精品成人区在线观看|