oracle中的資料對象

來源:互聯網
上載者:User

標籤:

oracle中的資料對象有表、視圖、索引、序列等

表的相關操作

1.建立表

方式一:                                                                     方式二:
create table person( create table person1 id number(18),                                    as name varchar2(5), select * from person age number(3), sex varchar2(4));

 2.刪除表

方式一:只會刪除表中的內容,不會刪除表結構truncate  delete                         方式二:刪除表結構
truncate table person drop table person
delete from person where id=123

 3.修改表

alter tableA.追加列alter table person add (address varchar2(20) default ‘shanghai‘)B.修改列alter table person modify (age number(6))使用modify可以修改資料類型,長度,預設值請注意:對預設值的修改,只對後面的資料才有效C.刪除列alter table person drop column age

 

二、視圖的相關操作

建立視圖                                 刪除視圖
create view person drop view person
as
select * from emp

視圖的優點:1.控制訪問,可以把主表中某些不想讓別人看見的資料隱藏

                 2.可以將多張表的資料構成一個視圖,簡化查詢

                 3.對視圖的修改操作會反映到基表中

 三、序列

建立序列                                            刪除序列   drop sequence seq_person

create sequence seq_person
increment by 1
start with 1
nomaxvalue
nocycle
nocache

使用序列實現主鍵遞增

insert into person values(seq_person.nextval,’ll’);

nextval表示下一個值

currval表示當前值

 

oracle中的資料對象

聯繫我們

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