Sei sulla pagina 1di 15

SQL> describe productoo

Name

Null?

Type

----------------------------------------- -------- ---------------------------CODIGO

NOT NULL VARCHAR2(30)

NOMBRE

NOT NULL VARCHAR2(30)

PRECIO

NUMBER(30)

SQL> insert into productoo (codigo, nombre, precio)


2 values ('1042453301', 'tornillo andres', 200) ;

1 row created.

SQL> insert into productoo (codigo, nombre, precio)


2 values ('001', 'tuercas andres', 50) ;

1 row created.

SQL> insert into productoo (codigo, nombre, precio)


2 values ('002', 'arandelas andres', 50) ;

1 row created.

SQL> insert into productoo (codigo, nombre, precio)


2 values ('003', 'tunel andres', 200) ;

1 row created.

SQL> insert into productoo (codigo, nombre, precio)


2 values ('004', 'sigueal andres', 150) ;

1 row created.

SQL> select* from productoo ;

CODIGO

NOMBRE

PRECIO

------------------------------ ------------------------------ ---------1042453301

tornillo andres

001

tuercas andres

002

arandelas andres

003

tunel andres

004

sigueal andres

200
50
50
200
150

SQL> describe cliente


Name

Null?

Type

----------------------------------------- -------- ---------------------------CODIGO

NOT NULL VARCHAR2(15)

NOMBRE

NOT NULL VARCHAR2(30)

APELLIDOS

NOT NULL VARCHAR2(30)

DIRECCION

VARCHAR2(60)

TELEFONO

VARCHAR2(15)

SQL> insert into cliente (codigo, nombre, apellidos, direccion, telefono)

2 values ('96010510420', 'andres felipe', 'montaa gavalo, 'calle 30',


'3005540189) ;
values ('96010510420', 'andres felipe', 'montaa gavalo, 'calle 30',
'3005540189)
*
ERROR at line 2:
ORA-00917: missing comma

SQL> insert into cliente (codigo, nombre, apellidos, direccion, telefono)


2 values ('96010510420', 'andres felipe', 'montaa gavalo', 'calle 30',
'3005540189) ;
ERROR:
ORA-01756: quoted string not properly terminated

SQL> insert into cliente (codigo, nombre, apellidos, direccion, telefono)


2 values ('96010510420', 'andres felipe', 'montaa gavalo', 'calle 30',
'3005540189') ;

1 row created.

SQL> insert into cliente (codigo, nombre, apellidos, direccion, telefono)


2 values ('111', 'felipe', 'mora', 'calle 30', '3005540189') ;

1 row created.

SQL> insert into cliente (codigo, nombre, apellidos, direccion, telefono)

2 values ('222', 'juan', 'martinez', 'calle 33', '3005540179') ;

1 row created.

SQL> insert into cliente (codigo, nombre, apellidos, direccion, telefono)


2 values ('333', 'luis', 'oviedo', 'calle 34', '3005547179') ;

1 row created.

SQL> insert into cliente (codigo, nombre, apellidos, direccion, telefono)


2 values ('444', 'luis', 'fandio', 'calle 35', '3205547179') ;

1 row created.

SQL> insert into cliente (codigo, nombre, apellidos, direccion, telefono)


2 values ('555', 'hugo', 'gomez', 'calle 36', '3205547') ;

1 row created.

SQL> select* from cliente ;

CODIGO

NOMBRE

APELLIDOS

--------------- ------------------------------ -----------------------------DIRECCION

TELEFONO

------------------------------------------------------------ --------------96010510420

andres felipe

montaa gavalo

calle 30

111

3005540189

felipe

mora

calle 30

222

3005540189

juan

martinez

calle 33

CODIGO

3005540179

NOMBRE

APELLIDOS

--------------- ------------------------------ -----------------------------DIRECCION

TELEFONO

------------------------------------------------------------ --------------333

luis

oviedo

calle 34

444

3005547179

luis

fandio

calle 35

555

3205547179

hugo

calle 36

6 rows selected.

SQL> describe factura

gomez
3205547

Name

Null?

Type

----------------------------------------- -------- ---------------------------CODIGO

NOT NULL VARCHAR2(15)

CODIGO_CLIENTE

NOT NULL VARCHAR2(15)

FECHA

DATE

TOTAL_FACTURA

NUMBER(20)

SQL> insert into cliente (codigo, codigo_cliente, apellidos, direccion, telefono)


2
SQL> insert into cliente (codigo, codigo_cliente, apellidos, direccion, telefono)
2
SQL> insert into cliente (codigo, codigo_cliente, fecha, total_factura)
2 vaalues ( '101', '96010510420', sysdate, 400) ;
vaalues ( '101', '96010510420', sysdate, 400)
*
ERROR at line 2:
ORA-00926: missing VALUES keyword

SQL> insert into cliente (codigo, codigo_cliente, fecha, total_factura)


2 values ( '101', '96010510420', sysdate, 400) ;
insert into cliente (codigo, codigo_cliente, fecha, total_factura)
*
ERROR at line 1:
ORA-00904: "TOTAL_FACTURA": invalid identifier

SQL> insert into cliente (codigo, codigo_cliente, fecha,total_factura )


2 values ( '101', '96010510420', sysdate, 400) ;
insert into cliente (codigo, codigo_cliente, fecha,total_factura )
*
ERROR at line 1:
ORA-00904: "TOTAL_FACTURA": invalid identifier

SQL> insert into cliente (codigo, codigo_cliente, fecha, total_factura)


2 values ( '101', '96010510420', sysdate, 400) ;
insert into cliente (codigo, codigo_cliente, fecha, total_factura)
*
ERROR at line 1:
ORA-00904: "TOTAL_FACTURA": invalid identifier

SQL> insert into factura (codigo, codigo_cliente, fecha, total_factura)


2 values ( '101', '96010510420', sysdate, 400) ;

1 row created.

SQL> insert into cliente (codigo, codigo_cliente, fecha, total_factura)


2 values ( '101', '96010510420', sysdate, 400) ;
insert into cliente (codigo, codigo_cliente, fecha, total_factura)
*

ERROR at line 1:
ORA-00904: "TOTAL_FACTURA": invalid identifier

SQL> insert into factura (codigo, codigo_cliente, fecha, total_factura)


2 values ( '101', '96010510420', sysdate, 400) ;
insert into factura (codigo, codigo_cliente, fecha, total_factura)
*
ERROR at line 1:
ORA-00001: unique constraint (SYSTEM.FACT_CODIGO_PK) violated

SQL>
SQL> insert into cliente (codigo, codigo_cliente, fecha, total_factura)
2 values ( '102', '111', sysdate, 200) ;
insert into cliente (codigo, codigo_cliente, fecha, total_factura)
*
ERROR at line 1:
ORA-00904: "TOTAL_FACTURA": invalid identifier

SQL> insert into factura (codigo, codigo_cliente, fecha, total_factura)


2 values ( '102', '111', sysdate, 200) ;

1 row created.

SQL> insert into factura (codigo, codigo_cliente, fecha, total_factura)


2 values ( '103', '222', sysdate, 800) ;

1 row created.

SQL> insert into factura (codigo, codigo_cliente, fecha, total_factura)


2 values ( '104', '333', sysdate, 10000) ;

1 row created.

SQL> insert into factura (codigo, codigo_cliente, fecha, total_factura)


2 values ( '105', '444', sysdate, 100) ;

1 row created.

SQL> select* from factura ;

CODIGO

CODIGO_CLIENTE FECHA

TOTAL_FACTURA

--------------- --------------- -------- ------------101

96010510420

102

111

20/11/14

200

103

222

20/11/14

800

104

333

20/11/14

10000

105

444

20/11/14

100

SQL> select* from detalle ;

20/11/14

400

no rows selected

SQL> describe detalle ;


Name

Null?

Type

----------------------------------------- -------- ---------------------------CODIGO_FACTURA

NOT NULL VARCHAR2(15)

CODIGO_PRODUCTO

VARCHAR2(15)

CANTIDAD

NUMBER(20)

TOTAL_ITEM

NUMBER(20)

SQL> insert into (codigo_factura, codigo_producto, caantidad, total_item)


2 values ('101', '001
3
SQL> insert into (codigo_factura, codigo_producto, caantidad, total_item)
2 values ('101', '001', 2,
3
SQL> insert into (codigo_factura, codigo_producto, cantidad, total_item)
2 values ('101', '001', 2, 3) ;
insert into (codigo_factura, codigo_producto, cantidad, total_item)
*
ERROR at line 1:
ORA-00928: missing SELECT keyword

SQL> insert into detalle (codigo_factura, codigo_producto, cantidad, total_item)

2 values ('101', '001', 2, 3) ;

1 row created.

SQL> insert into detalle (codigo_factura, codigo_producto, cantidad, total_item)


2 values ('102', '002', 5, 6) ;

1 row created.

SQL> insert into detalle (codigo_factura, codigo_producto, cantidad, total_item)


2 values ('103', '003', 5, 5) ;

1 row created.

SQL> insert into detalle (codigo_factura, codigo_producto, cantidad, total_item)


2 values ('106', '004', 10, 10) ;
insert into detalle (codigo_factura, codigo_producto, cantidad, total_item)
*
ERROR at line 1:
ORA-02291: integrity constraint (SYSTEM.DETALLE_COD_FACT_FK) violated parent
key not found

SQL> insert into detalle (codigo_factura, codigo_producto, cantidad, total_item)


2 values ('104', '004', 10, 10) ;

1 row created.

SQL> insert into detalle (codigo_factura, codigo_producto, cantidad, total_item)


2 values ('105', '1042453301', 10, 10) ;

1 row created.

SQL> select* from detalle ;

CODIGO_FACTURA CODIGO_PRODUCTO CANTIDAD TOTAL_ITEM


--------------- --------------- ---------- ---------101

001

102

002

103

003

104

004

10

105

1042453301

SQL> spool of

10
10

10

Potrebbero piacerti anche