<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)  編輯  收藏 所屬分類: 程序人生
    主站蜘蛛池模板: 亚洲bt加勒比一区二区| 亚洲综合久久夜AV | 亚洲区视频在线观看| 99在线在线视频免费视频观看| 亚洲AV无码专区在线播放中文| 毛片免费在线观看| 久久亚洲国产成人精品性色| 小日子的在线观看免费| 亚洲码在线中文在线观看| 欧洲乱码伦视频免费| 亚洲久热无码av中文字幕| 国产精品深夜福利免费观看| 欧洲精品码一区二区三区免费看 | 最近2019中文字幕mv免费看| 亚洲中文字幕无码中文| 国产区卡一卡二卡三乱码免费| 瑟瑟网站免费网站入口| 亚洲无码在线播放| 99热这里有免费国产精品| 亚洲一级高清在线中文字幕| 国产男女猛烈无遮挡免费视频 | 一个人免费观看视频www| 朝桐光亚洲专区在线中文字幕 | 国产免费AV片在线观看| 亚洲国产亚洲片在线观看播放| 成人毛片18女人毛片免费96| 老外毛片免费视频播放| 久久99国产亚洲精品观看| 大地资源在线观看免费高清| 一区二区三区精品高清视频免费在线播放 | 一二三四在线观看免费中文在线观看| 国产亚洲日韩在线三区| 免费观看美女用震蛋喷水的视频| 亚洲精品无码中文久久字幕| 国产亚洲精品岁国产微拍精品| 亚洲免费二区三区| 免费观看又污又黄在线观看| 久久亚洲AV成人无码电影| 四虎亚洲国产成人久久精品| 99视频有精品视频免费观看| 综合一区自拍亚洲综合图区|