sqlplus

1、ed a(使用记事本编辑脚本)
2、@a
3、set linesize 100
  set pagesize 30
4.执行d盘下的demo.txt   @d:\demo.txt如果文件的后缀为demo.sql则不用加后缀:@d:demo
5.conn 用户名/密码 [AS SYSDBA|SYSOPER]   若用户名为sys则必须加AS SYSDBA,以系统管理员身份连接数据库
6.访问其他用户的表;select * from scott.emp;
7.当前连接的用户:show user;
8.得到所有表的名字:select * from tab;
9.查看表的完整结构:desc emp;
10.number(4):数字长度为4  varchar2表示字符串,只能容纳10个字符 DATE:日期  number(7,2)长度为7,小数位为2
11.继续使用上次操作:/
12 DML:数据操纵语言:查询修改  DDL:数据定义语言:创建,增加 删除  DCL数据控制语言:定义用户的权限

所有查询:
13.select empno 编号,empname 姓名,job 工作;
14.去除重复的行: select distinct job from emp;如果查询多列,则只有所有的列都重复时才会去掉;
15.字符串连接操作,使用||操作符,如果要加一些字符则用''将固定的信息括起来:select '编号是:' || empno '的雇员的姓名是' || empname from emp;
16.select empname,sal * 12 income from emp;起别名时回避中文:

限定查询:where
select * from emp where sal > 1500;
得到奖金的员工:select * from emp where comm is not null;
select * from emp where sal > 1500 and comm is not null;
通过括号表示一组操作:select * from emp where not (sal > 1500 and comm is not null);
select * from emp wher sal between 1500 and 3000;
select * from emp where hiredate between '1-1 月 -81' and '31-12 月 -81

你可能感兴趣的:(sqlplus)