sql base de datos
CREATE TABLE clientes
(
Num_clie smallint NOT NULL PRIMARY KEY,
Empresa char(20) NOT NULL,
Repclie smallint,
Limite_credito numeric
)
--AHORA INSERTAMOS LOS SIGUIENTES REGISTROS
USE
VENTAS
GO
INSERT INTO clientes VALUES (2101 , ' Jones Mfg. ' , 106 , 65000)
INSERT INTO clientes VALUES (2102 , ' First. Corp . ' , 101, 65000)
INSERT INTO clientes VALUES (2103 , ' Acme Mfg . ' , 105 , 50000)
INSERT INTO clientes VALUES (2105 , ' AAA Investments' , 101 , 45000)
INSERT INTO clientes VALUES (2106 , 'Fred Lewis Corp.' , 102 , 65000)
INSERT INTO clientes VALUES (2107 , ' Ace International ' , 110 , 35000)
INSERT INTO clientes VALUES (2108 , ' Holm Landis' , 109 , 55000)INSERT INTO clientes VALUES (2109 , ' Chen Associates' , 103 , 25000)
INSERT INTO clientes VALUES (2111 , ' JCP Inc . ' , 103 , 50000)
INSERT INTO clientes VALUES (2112 , ' Zetacorp' , 108 , 5000)
INSERT INTO clientes VALUES (2113 , ' Ian Schmidt ' , 104 , 20000)
INSERT INTO clientes VALUES (2114, 'Orion Corp . ' , 102 , 20000)
INSERT INTO clientes VALUES(2115 , 'Smithson Corp . ' , 101 , 20000)
INSERT INTO clientes VALUES (2117 , 'J . P. Sinclair' , 106 , 35000)
INSERT INTO clientes VALUES (2118 , 'Midwest Systems' , 108 , 60000)
INSERT INTO clientes VALUES (2119 , 'Solomon Inc. ' , 109 , 25000)
INSERT INTO clientes VALUES (2120 , 'Rico Enterprises' , 102 , 50000)
INSERT INTO clientes VALUES(2121 , 'QMA Assoc. ' , 103 , 45000)
INSERT INTO clientes VALUES (2122 , 'Three-Way Lines' , 105 , 30000)
INSERT INTO clientes VALUES (2123 , 'Carter Sone ' , 102 , 40000)
INSERT INTO clientes VALUES (2124 , 'Peter Brothers ' , 107 , 40000)
--2.-AHORA CREAMOS LA TABLA repventas
DROP TABLE repventas
CREATE TABLE repventas(
Num_empl smallint NOT NULLPRIMARY KEY,
Name varchar(25) NOT NULL,
Edad tinyint,
Oficina_rep smallint,
Titulo varchar(15),
Contrato datetime NOT NULL,
Director smallint,
Cuota numeric,
Ventas numeric NOT NULL)
--ENSEGUIDA INSERTAMOS LOS SIGUIENTES REGISTROS:
INSERT INTO repventas VALUES (101,'Dan Roberts' , 45, 12 , 'Rep Ventas' , '1986-10-20' , 104 , 300000 , 305673)
INSERT INTO repventasVALUES (102 ,'Sue Smith' , 48 , 21 , 'Rep Ventas' , '1986-12-12' , 108 , 350000, 474050)
INSERT INTO repventas VALUES (103 ,'Paul Cruz' , 29 , 12 , 'Rep Ventas' , '1987-03-01' , 104 , 275000 , 286775)
INSERT INTO repventas VALUES (104 ,'Bob Smith' , 33 , 12 , 'Dir Ventas' , '1987-05-19' , 106 , 200000 , 142594)
INSERT INTO repventas VALUES (105 ,'BillAdams' , 37 , 13 , 'Rep Ventas' , '1988-02-12' , 104 , 350000 , 367911)
INSERT INTO repventas VALUES (106 ,'Sam Clark' , 52 , 11 , 'VP Ventas' , '1988-06-14' , null , 275000 , 299912)
INSERT INTO repventas VALUES (107 ,'Nancy Angelli' , 49 , 22 , 'Rep Ventas' , '1988-11-14' , 108 , 300000, 186042)
INSERT INTO repventas VALUES (108 ,'Larry Fitch' , 62 , 21 ,'Dir Ventas ' , '1989-10-12' , 106 , 350000, 361865)
INSERT INTO repventas VALUES (109 ,'Mary Jones' , 31 , 11 , 'Rep Ventas' , '1999-10-12' , 106 , 300000 , 392725)
INSERT INTO repventas VALUES (110 ,'Tom Snyder' , 41 , null , ' Rep ventas' , '1990-01-13' , 101 , null , 75985)
--3.- CREAMOS LA TABLA oficinas
CREATE TABLE oficinas
(
Oficina smallint NOT NULL PRIMARYKEY,
Ciudad varchar(20) NOT NULL,
Reqion varchar(15) NOT NULL,
Dir smallint REFERENCES repventas (Num_empl),
Objetivo numeric,
Ventas numeric not null
)
--UNA VEZ CREADA LA TABLA oficinas INSERTAMOS LOS SIGUIENTES REGISTROS
INSERT INTO oficinas VALUES (11, 'New York' , ' Este' , 106 , 575000 , 692637)
INSERT INTO oficinas VALUES (12, 'Chicago' , 'Este' , 104 ,...
Regístrate para leer el documento completo.