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

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

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

    隨筆 - 44  文章 - 78  trackbacks - 0
    <2008年12月>
    30123456
    78910111213
    14151617181920
    21222324252627
    28293031123
    45678910

     Happy 牛 Year
    一、一周至少寫一篇博文;
    二、每天至少學習半個小時。
    三、奔向小牛!

    常用鏈接

    留言簿(6)

    我參與的團隊

    隨筆分類

    隨筆檔案

    文章檔案

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    ?????--創建表空間
      create tablespace yyspace
      datafile ’d:\yyspace.dbf’
      size 10m
      autoextend on;
      --創建臨時表空間
      create temporary tablespace yytemp
      tempfile ’d:\yytemp.dbf’
      size 10m
      autoextend on;
      --創建用戶
      create user yangrs
      identified by yangrs;
      alter user yangrs
      default tablespace yyspace;
      alter user yangrs
      temporary tablespace yytemp;
      --賦權
      grant connect,resource to yangrs
      --connect
      connect yangrs/yangrs;
      --建表
      --刪表
      drop table stuInfo
      create table stuInfo
      (
      s_id number(4),
      s_name varchar2(10),
      s_sex char(2),
      s_age number(3),
      s_birthday date default(sysdate),
      s_note varchar2(50)
      );
      create table stuScore
      (
      stuid number(4),
      scoreid varchar2(10),
      score number(3)
      );
      drop table stuScore;
      --加約束
      --主鍵
      alter table stuInfo
      add constraint PK_s_id primary key(s_id);
      --檢查
      alter table stuInfo
      add constraint CK_s_sex check(s_sex in (’男’,’女’));
      alter table stuInfo
      add constraint CK_s_age check(s_age>0 and s_age<100);
      --加默認的不行
      alter table stuInfo
      add constraint DK_s_birthday default(systimestamp );
      --外鍵
      alter table stuScore
      add constraint FK_stuid foreign key(stuid) references stuInfo(s_Id);
      --insert
      insert into stuInfo(s_id,s_name,s_age,s_Sex,s_Note) values(1000,’劉德華’,20,’男’,’just do it’);
      insert into stuInfo(s_Id,s_name,s_age,s_sex,s_birthday,s_note) values(1001,’yangrs’,19,’男’,to_date(’1989-01-01’,’yyyy-mm-dd’),’i am what i am’);
      insert into stuInfo(s_Id,s_name,s_age,s_sex,s_birthday,s_note) values(1002,’yangrs2’,19,’男’,to_date(’1989-01-01’,’yyyy-mm-dd’),’i am what i am’);
      insert into stuInfo(s_Id,s_name,s_age,s_sex,s_birthday,s_note) values(1003,’yangrs3’,19,’男’,to_date(’1989-01-01’,’yyyy-mm-dd’),’i am what i am’);
      insert into stuInfo(s_Id,s_name,s_age,s_sex,s_birthday,s_note) values(1004,’yangrs4’,19,’男’,to_date(’1989-01-01’,’yyyy-mm-dd’),’i am what i am’);
      insert into stuInfo(s_id,s_name,s_age,s_Sex,s_Note) values(1005,’華仔’,20,’男’,’just do it’);  
      insert into stuScore(Stuid,scoreid,Score) values(1001,’1’,100);
      insert into stuScore(Stuid,scoreid,Score) values(1001,’1’,100);
      insert into stuScore(Stuid,scoreid,Score) values(1000,’1’,100);
      insert into stuScore(Stuid,scoreid,Score) values(1000,’1’,100);

      --復制表
      create table stuBak
      as select * from stuInfo;
      --復制表結構
      create table stuBak2
      as select * from stuInfo where 1=2;
      --在已有的表結構中插入數據
      insert into stuBak2
      select * from stuBak;
      update stuBak set s_sex=’男’;
      savepoint mark;
      rollback to savepoint mark;
      rollback;
      --給予其他用戶權限
      connect scott/tiger@itjob;
      grant select on emp to yangrs; --只給查詢
      grant all on emp to yangrs --給所有的權限
      connect yangrs/yangrs@itjob;
      select * from scott.emp;
      -- 取消權限
      connect scott/tiger@itjob;
      revoke select on emp from yangrs;
      connect yangrs/yangrs@itjob;
      select * from scott.emp; --此時已經連接不上去了
      --偽列 rowid rownum
      select rowid,rownum from stuInfo;
      --用于分頁
      select * from (select rownum as num,stuInfo.* from stuInfo) where num>5;
      --sqlserver中是使用top來分頁
      --啞元表
      select sysdate from dual;
      select systimestamp from dual;
      --對表的修改
      alter table stuInfo add(s_sal number(3));
      --is null and is not null
      select * from stuInfo where s_note is null;
      select * from stuInfo where s_name like ’y%’; --%代筆任意個字符
      select * from stuInfo where s_name like ’y_’; --—_代表一個字符
      select * from stuInfo where s_name like ’y?’;
      select * from stuInfo order by s_age desc; -- 排序
      select * from stuInfo order by s_birthday asc;
      select * from stuInfo order by s_age desc,s_birthday asc;
      --可以有兩個條件
      --分組
      select * from stuInfo where s_name<>’yangrs’;
      select * from stuInfo where s_age=19;
      select * from stuInfo where s_name<>’yangrs%’; --這樣是不行的
      --調用函數
      select sum(s_sal) as 獎學金 from stuInfo;
      select avg(s_age) 平均年齡 from stuInfo;
      select s_name,s_age from stuInfo group by s_age;
      select ’hell’||’loworld’ from dual;
      select 1+1 from dual;
      --轉換大小寫
      update stuInfo set s_name=upper(s_name);
      update stuInfo set s_name=lower(s_name);
      --轉換ascii碼
      select ascii(’A’) from dual;
      select ’Hello’||’\t’||’World’ from dual;
      select ’Hello’||chr(9)||’World’ from dual;
      select to_char(sysdate,’yyyy/mm/dd hh24:mi:ss’) from dual;
      select add_months(sysdate,-12) from dual;
      -- 一年以前的今天
      select last_day(sysdate) from dual;
      select to_char(sysdate,’yyyy/mm/dd’) from dual; --改變日期格式
      select to_char(to_date(’19990214’,’yyyymmdd’),’yyyy"我"mm"月"dd"日"’) from dual;
      select to_char(to_date(’19990214’,’yyyymmdd’),’yyyy"我"mm"月"dd"日"’) from dual;?

    ?????ref:http://www.zlksw.cn/html/jsj/Oraclerenzheng/xuexiziliao/200812/24-7834.html

    posted on 2008-12-26 10:40 Tiger1102 閱讀(516) 評論(0)  編輯  收藏 所屬分類: 程序人生
    主站蜘蛛池模板: 爱丫爱丫影院在线观看免费| 在线91精品亚洲网站精品成人| A毛片毛片看免费| 亚洲国产成人久久精品99| 羞羞漫画在线成人漫画阅读免费| 暖暖免费高清日本一区二区三区| 亚洲精品女同中文字幕| 午夜爱爱免费视频| 狼人大香伊蕉国产WWW亚洲| 情侣视频精品免费的国产| 欧洲亚洲综合一区二区三区| 亚洲 国产 图片| 七次郎成人免费线路视频| 亚洲另类激情综合偷自拍图| 亚洲免费人成在线视频观看| 久久久亚洲欧洲日产国码aⅴ | 亚洲理论在线观看| 0588影视手机免费看片| 亚洲av无码一区二区三区天堂古代 | 久久亚洲精品人成综合网| 亚洲第一网站免费视频| 性xxxx黑人与亚洲| 国产精品麻豆免费版| 黄页视频在线观看免费| 国产亚洲一区二区三区在线| 最近免费中文字幕mv电影| 亚洲国产精品免费观看| 亚洲成av人片一区二区三区| 大地影院MV在线观看视频免费| 91亚洲国产成人久久精品网站| 最近最好的中文字幕2019免费 | 亚洲最大中文字幕| 国产美女a做受大片免费| 中文字幕免费人成乱码中国| 亚洲小视频在线播放| 国产人成免费视频| 99热在线免费观看| 青草久久精品亚洲综合专区| 久久亚洲高清观看| 日本免费人成黄页在线观看视频| A片在线免费观看|