Oracle基礎教程之表的增刪改查

來源:互聯網
上載者:User

Oracle表管理-----怎麼樣建立表
-------------------------------------------------------
建表
  學生表
    sql>create table student(
 xh number(4),--學號
 xm varchar2(20),---姓名
 sex char(2),---性別
 birthday date,---出生日期
 sal number(7,2),----獎學金
 );
---------------------------------------------------------
表修改
添加一個欄位
 sql>alter table student add(classid number(2));
修改欄位的長度
  sql>alter table student modify (xm varchar2(30));
刪除一個欄位
  sql>alter table student drop column sal;
修改表的名字
 sql>rename student to stu
刪除表
  sql>drop table student;

---------------------------------------------------------
添加資料
Oracle中的預設日期格式‘DD-MON-YY’dd  日子(天) mon 是月

份 yy是2位的年
改日期的預設格式:
alter seesion set nls_date_format = 'yyyy-mm-dd'

==========================================================
當你在資料庫中插入了null值的資料的時候,你想根據這些null來

把這個資料查出來
錯誤的:select *  from student where birthday='';
正確的是:select * from student  where birthday is null;
這是Oracle和其它資料庫之間不一樣的地方  請牢記
select * from student  where birthday is not null;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.