標籤:別名 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);
關於資料庫的一些基本知識