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;