Procedure Language/Structure query Language 一.关于语言学习 1.数据类型 2.语法 通过例子来学习很快就能明白 set serverputout on: begin dbms_output.put_line(‘HelloWorld!’): end: 二.结构(declare(可选).begin.exception(可选).end) 1.declare例子 declare v_name varchar2(20); begin v_name := '…
SQL语法 LIMIT select col from table limit number select * from table limit number LIKE select * from table where col LIKE '%in%' select * from table where col NOT LIKE '%in%' 通配符 通配符必须与LIKE一起使用 % -- 替代一个或者多个字符 _ -- 替代一个字符 [charlist] -- 字符列中的任何单一字符 [!ch…
-- 1. 使用一个变量 declare -- Local variables here v_name ); begin -- Test statements here select t.user_name into v_name from pay_mer_order t ; dbms_output.put_line(v_name); end; -- 2. 使用多个变量 declare -- Local variables here v_name ); v_trans_no ); v_app_c…
SELECT [ID] ,[UserID] ,[StartDate] ,[EndDate] ,[CreateUser] ,[CreateDate] ,[LastEditUser] ,[LastEditDate] FROM [DB_Base].[dbo].[DB_Contracts] ,(SELECT UserID AS U,MAX(EndDate) AS E FROM dbo.DB_Contracts GROUP BY UserID) temp WHERE temp.U = dbo.DB_Con…
前言 好好学习,天天向上. 正文 好像也是一个不难的问题,刚视频里看到的,就记一下吧. 下面是表中原始的数据结构,做了一个倒叙排序: select * from Employee order by Salary desc 首先来看一下如何取Salary第二的记录. --获取salary排行第二的人的信息 select top 1 * from Employee where Salary < (select max(salary) from Employee ) order by Salary d…
主机字符串:as sysdba alter user scott account unlock;//解锁scott,不会就谷歌检索 DML语句,增.删.查.改 select语句:熟悉表结构 desc emp; number(4) 4位数字类型number(7,2) 7位数字,2位小数varchar2(10) 10位可变长度字符串date 日期类型 select * from salgrade s:select s.* from salgrade s; select ename, sal * 12…
1.定义基本变量: 2.引用型的变量: set serveroutput on declare pename emp.ename%type; psal emp.sal%type; begin select ename,sal into pename,psal from emp where empno='7521'; dbms_output.put_line(pename||'的薪水是'||psal); end; / 3.记录型变量: set serveroutput on d…
select * from protype;select * from product;---笛卡尔连接查询(交叉连接)select * from protype,product;select * from protype cross join product;---标准写法---内链接查询select * from protype pt,product pd where pt.pt_id=pd.p_type;select * from protype pt inner join product…
目录 NOT NULL约束 INDEX 索引 CHECK 约束 DEFAULT 约束 UNIQUE 约束 PRIMARY KEY 约束 FOREIGN KEY 约束:简单的说,就是创建表的时候,对表或者其中的列的属性的初始化或修改或删除. NOT NULL约束 强制列不接受NULL值 CREATE TABLE forLearn ( ID int NOT NULL,City varchar(255)); INDEX 索引 特点: 在不读取整个表的情况下,索引使数据库应用程序可以更快地查找数据. 但…
-- declare type vsal_table is table of emp.sal%type; a vsal_table; begin --必须得初始化 并且有数量上的区分 从一开的 a:=vsal_table(1000,2000,30000); dbms_output.put_line(a(1)); end; --使用嵌套表的案例 --定义一个类型 create type stu_name is table of varchar2(20); create table…
阅读目录 一 单表查询的语法 二 关键字的执行优先级(重点) 三 简单查询 四 WHERE约束 五 分组查询:GROUP BY 六 HAVING过滤 七 查询排序:ORDER BY 八 限制查询的记录数:LIMIT 九 使用正则表达式查询 一 单表查询的语法 SELECT 字段1,字段2... FROM 表名 WHERE 条件 GROUP BY field HAVING 筛选 ORDER BY field LIMIT 限制条数 二 关键字的执行优先级(重点) 重点中的重点:关键字的执行优先级 f…