You are on page 1of 4

SQL> select * from clientes where nif='55971122-J';

NIF NOMBRE APELLIDOS S EC EL EDA_EDA_ID CIU


---------- --------------- ------------------------- - -- -- ---------- ---
55971122-J Nombre9040 Apellido9040 Apellido9040 M SO AC 1 26

SQL> select * from clientes where nif='10040198-T';

NIF NOMBRE APELLIDOS S EC EL EDA_EDA_ID CIU


---------- --------------- ------------------------- - -- -- ---------- ---
10040198-T Nombre4168 Apellido4168 Apellido4168 M DI IN 1 29

SQL> select sql_text from v$sqlarea where sql_text like '%clientes%';

SQL_TEXT
-------------------------------------------------------------------------------
select * from clientes where rownum<5
select * from clientes where nif='13215423J'
select * from clientes where nif='13215423-J'
select * from clientes where nif='17441167-R'
select * from clientes where nif='52347055-J'
select * from clientes where nif='55971122-J'
select sql_text from v$sqlarea where sql_text like '%clientes%'

select * from clientes where nif=:variable;

SQL> variable nif varchar2(15)

SQL> exec :nif:='10012292-T'

PL/SQL procedure successfully completed.

SQL> select * from clientes where nif=:nif;

NIF NOMBRE APELLIDOS S EC EL EDA_EDA_ID CIU


---------- --------------- ------------------------- - -- -- ---------- ---
10012292-T Nombre1619 Apellido1619 Apellido1619 H SE IN 1 29

SQL> exec :nif:='10027301-L'

PL/SQL procedure successfully completed.

SQL> select * from clientes where nif=:nif;

NIF NOMBRE APELLIDOS S EC EL EDA_EDA_ID CIU


---------- --------------- ------------------------- - -- -- ---------- ---
10027301-L Nombre3347 Apellido3347 Apellido3347 H SO IN 3 15

SQL> exec :nif:='10039594-Q'

PL/SQL procedure successfully completed.

SQL> select * from clientes where nif=:nif;

NIF NOMBRE APELLIDOS S EC EL EDA_EDA_ID CIU


---------- --------------- ------------------------- - -- -- ---------- ---
10039594-Q Nombre4283 Apellido4283 Apellido4283 H SE IN 3 6

SQL> exec :nif:='10040198-T'

PL/SQL procedure successfully completed.

SQL> select * from clientes where nif=:nif;

NIF NOMBRE APELLIDOS S EC EL EDA_EDA_ID CIU


---------- --------------- ------------------------- - -- -- ---------- ---
10040198-T Nombre4168 Apellido4168 Apellido4168 M DI IN 1 29

SQL> exec :nif:='10063225-D'

PL/SQL procedure successfully completed.

SQL> select * from clientes where nif=:nif;

NIF NOMBRE APELLIDOS S EC EL EDA_EDA_ID CIU


---------- --------------- ------------------------- - -- -- ---------- ---
10063225-D Nombre532 Apellido532 Apellido532 H SE AC 2 10

SQL> exec :nif:='10066484-R'

PL/SQL procedure successfully completed.

SQL> select sql_text from v$sqlarea where sql_text like '%clientes%';

SQL_TEXT
-----------------------------------------------------------------------------------
-
select * from clientes where nif=:nif
select * from clientes where rownum<5
select * from clientes where nif='13215423J'
select * from clientes where nif='13215423-J'
select * from clientes where nif='17441167-R'
select * from clientes where nif='52347055-J'
select * from clientes where nif='55971122-J'
select nif from vuelos.clientes where rownum<10
select sql_text from v$sqlarea where sql_text like '%clientes%'

SQL> create table reservas_estado


2 as select r.*, 'PAGADO' estado
3 from reservas r;

Tabla creada.

SQL> alter table reservas_estado modify estado varchar2(10);

Tabla modificada.

SQL> update reservas_estado set estado='IMPAGADO' where


substr(id_reserva,3,2)='JA';

42 filas actualizadas.

SQL> commit;
Confirmaci�n terminada.

SQL> create index idx_reservas_estado on reservas_estado2(estado);

�ndice creado.

SQL> begin
2 dbms_stats.gather_table_stats(
3 ownname=>'VUELOS',
4 tabname=>'RESERVAS_ESTADO',
5 method_opt=>'for all columns size 75',
6 cascade=>true);
7 end;
8 /

Procedimiento PL/SQL terminado correctamente.

SQL> explain plan for


2 select * from reservas_estado
3 where estado='PAGADO';

Explicado.

SQL> @?/rdbms/admin/utlxpls

PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------
--

Plan hash value: 940015665

-----------------------------------------------------------------------------------
--
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time
|
-----------------------------------------------------------------------------------
--
| 0 | SELECT STATEMENT | | 171K| 8184K| 361 (2)| 00:00:05
|
|* 1 | TABLE ACCESS FULL| RESERVAS_ESTADO | 171K| 8184K| 361 (2)| 00:00:05
|
-----------------------------------------------------------------------------------
--

Predicate Information (identified by operation id):


---------------------------------------------------

1 - filter("ESTADO"='PAGADO')

SQL> explain plan for


2 select * from reservas_estado
3 where estado='IMPAGADO';

Explicado.

SQL> @?/rdbms/admin/utlxpls
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------
-----

Plan hash value: 2327085349

-----------------------------------------------------------------------------------
-----
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time
|
-----------------------------------------------------------------------------------
-----
| 0 | SELECT STATEMENT | | 62 | 3038 | 4 (0)|
00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| RESERVAS_ESTADO |62 | 3038 | 4 (0)|
00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_RESERVAS_ESTADO | 62 | | 3 (0)|
00:00:01 |
-----------------------------------------------------------------------------------
-----

Predicate Information (identified by operation id):


---------------------------------------------------

2 - access("ESTADO"='IMPAGADO')

select * from facturas where estado=:estado;

You might also like