Вы находитесь на странице: 1из 3

--clase 04

use master

---Elimina la Base de Datos Ventas siu lo encuentra.


IF DB_ID('vENTAS') IS NOT NULL
BEGIN
DROP DATABASE VENTAS
END
ELSE
PRINT 'LA BASE DE DATOS NO EXISTE'

--CREAR LA BD
CREATE DATABASE VENTAS
--USAR BD VENTAS
USE VENTAS

--CREANDO NUESTRO TIPO DE DATO


USE VENTAS
GO
EXEC sp_addtype descrip,'varchar(20)','not null'
go

--CREANDO TABLA CLIENTES


CREATE TABLE CLIENTES
(
NUM_CLI INTEGER NOT NULL,
empresa descrip,
rep_cli integer null,
limite_credito money null
)
go
DROP TABLE CLIENTES

CREATE TABLE repVentas


(
num_empl integer not null,
nombre descrip,
edad integer,
oficina_rep integer,
titulo varchar (10)
)

CREATE TABLE Proveedores


(
num_provee integer not null,
nombre descrip,
direccion varchar(20),
contacto descrip
)

CREATE TABLE Oficinas


(
oficina integer not null,
ciudad descrip,
region varchar (10),
dir integer,
objetivo money,
ventas money not null
)

CREATE TABLE Pedidos


(
Num_pedido integer not null,
fecha_pedido datetime not null,
clie integer,
rep integer,
fab char(3),
producto char (5)
)

CREATE TABLE Productos


(
id_fab char(3) not null,
id_producto char(5) notnull,
Descripcion descrip,
precio money not null,
existencias integer not null
)

Вам также может понравиться