Oracle中的資料類型和表的管理

來源:互聯網
上載者:User

日期類型
   date 包含年月日和時分秒
   timestamp 這是Oracle9i對date資料類型的擴充 (時間戳記)date類型的時間更精確
 

 圖片類型

   blob 位元據可以存放圖片 和聲音 4G


 oracle表的管理

 建立表一個student表的語句

  create table student(
    xh number(4),
    xm varchar2(20),
    sex char(2),
    birthday date,
    sal number(7,2)
    );
  建立表一個Tclass表的語句

   create table Tclass(
     class_id number(2),
     cName varchar2(20)
     );


   修改表
   在Student表中添加一個欄位class_id
   alter table student add(class_id number(2));

   在Student表中修改一個欄位xm
   alter table student modify (xm varchar2(30))

   在Student表中刪除一個欄位xm
  alter table student drop column xm;

  怎樣改oracle中的預設日期(因為在oracle中日期預設為 "日月年")

   alter session set nls_date_format='yy-mm-dd'


  使用is 關鍵字查詢null值
  select * from student where birthday is null;
 

  使用like關鍵字
  select * from student where xh like '%3%';

  更新student表中xh=1234的birthday為 null值
  update student set birthday = null where xh = 1234

  刪除資料
  delete from student;
 
 

 oracle 支援交易回復
 設定 一個點 savepoint a ;
 執行 delete from student 語句 刪除表中的所有資料
 然後回到 我們設定的點a

 執行的語句 :rollback to a ;


 執行完後我們在去查詢資料表的資料 將會 回到刪除前的狀態。

 使用truncate 刪除表 表的結構還在, 不寫日誌,無法找回刪除的記錄 , 但速度快。
執行語句:truncate table student

 使用delete 刪除表
 使用delete刪除會將表的結構刪除 這張表將不會存在。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.