Oracle使用(一)_数据库登录_通配符

1、DBA登录

sqlplus  /nolog

conn  sys/管理员用户名@orcl  as sysdba;

alter  user scott account unlock/lock;

2、普通用户登录

conn scott/tiger@orcl;

3、plsql
命令窗口:等价cmd

4、查询所有表的详细信息

select * from user_tables;

5、查询所有表

select * from tab;

6、数据字典

7、给表和表中的列添加注释
--给表添加注释

comment on table emp is '雇员表';

--给列添加注释

comment on column emp.ename is '雇员姓名';

8、sql学习
/**
SELECT [DISTINCT] [*,column alias,column name] from table alias
[] 表示可选条件,可写可不写
*/

--查询部门编号为10的员工

select deptno,ename,job from emp where deptno = 10;

-- distinct 表示去重

select distinct deptno from emp;

--distinct 多个列去重,每个字段子不一样才去重

select distinct deptno,sal from emp;

-- 再查询过程中可以给列和表添加别名
-- 查询多个列,列取别名可省略as,也可不省略,表取别名不能用as

select e.empno 雇员编号,e.ename 雇员姓名,e.job 职位 from emp e where e.deptno = 10;

select e.empno as 雇员编号,e.ename as 雇员姓名,e.job as 职位 from emp e where e.deptno = 10;

-- 如果别名包含空格必须,将别名用""括起来

select e.empno as "雇员 编号",e.ename as "雇员 姓名",e.job as 职位 from emp e where e.deptno = 10;

--查询表中的所有字段可以用,但是实际项目中不能随便用,按需查询就行

select * from emp;

sql中通配符使用方便,但是会降低检索性能

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容