关于数据库的一些基本知识

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);

猜你喜欢

转载自www.cnblogs.com/fltkxy/p/9381331.html