關於資料庫的一些基本知識

來源:互聯網
上載者:User

標籤:別名   ima   大量   基本知識   通配   作業系統   rom   元組   電腦系   

Database:資料庫,是長期儲存在電腦內、有組織的、可共用的大量資料的集合。
DBMS:資料庫管理系統,是位於使用者與作業系統之間的一層資料管理軟體,用於科學地組織、儲存和管理資料、高效地擷取和維護資料。
DBS:資料庫系統,指在電腦系統中引入資料庫後的系統,一般由資料庫、資料庫管理系統、應用系統、資料庫管理員(DBA)構成。
資料庫的三級系統結構:外模式、模式和內模式。
主鍵:能夠唯一地標識一個元組的屬性或屬性群組稱為關係的鍵或候選索引鍵。若一個關係有多個候選索引鍵則可選其一作為主鍵(Primary key)。
外鍵如果一個關係的一個或一組屬性引用(參照)了另一個關係的主鍵,則稱這個或這組屬性為外碼或外鍵(Foreign key)。

資料庫的操作:
查詢:select * from table_name
    例:select * from student
修改:update table set row=value where row=value
    例:update student set name=‘Mike‘ where name=‘John‘
增加:insert into table values(值1,值2,值3,...)
    例:insert into student values(1,‘one’,25)
        insert into student (id,name)values(1,‘one’);
刪除:delete from table where row=value
    例:delete from student where name=‘one‘

like 與萬用字元(_和%)的使用
select * from student_1 where address like ‘%廣州市%‘
select * from student_1 where address like ‘___廣州%‘

distinct()去重函數;
select distinct(name) from student_1

排序:
降序:select * from student_1 order by id desc
升序:一般預設 select * from student_1 order by id asc

Alias(取別名):
select name "名字",age "年齡" from student_1

and:
select * from student_1 where age=20 and address like ‘廣東%‘

or:
select * from student_1 where address like ‘湖南%‘ or address like ‘湖北%‘

in:
select * from student_1 where age in(18,20)

between:
select * from student_1 where age between 18 an 19

隱藏列:rownum
可視化編輯:
select a. *,a.rowid from student_1 a;

刪除列中資料:
update table_name set 欄位=null;
commit;

刪除整個列:
alter table 表名 drop column 列名;

插入一列資料:
alter table tablename add (columnname datatype);

關於資料庫的一些基本知識

聯繫我們

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