0% found this document useful (0 votes)
55 views3 pages

Select From Insert Into Values: 'Franco' 'San Andres'

The document describes SQL queries to perform various operations on database tables like customers, inventory, and invoices. These include inserting new customer and product records, updating customer and product details, deleting a customer, adding a new invoice, and inserting invoice line items along with calculations. Tables are created for customers, inventory, invoices and invoice details with primary and foreign keys.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views3 pages

Select From Insert Into Values: 'Franco' 'San Andres'

The document describes SQL queries to perform various operations on database tables like customers, inventory, and invoices. These include inserting new customer and product records, updating customer and product details, deleting a customer, adding a new invoice, and inserting invoice line items along with calculations. Tables are created for customers, inventory, invoices and invoice details with primary and foreign keys.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

--1.

Ingreso de clientes nuevos


SELECT * FROM Cliente
INSERT INTO Cliente VALUES (1,'Franco','San Andres',58632148)

--2. Modificar Clientes

UPDATE Cliente SET Nombre='Poporopo', Direccion='Santo Domingo',


Telefono='50006320' where Nit='3'

--3. Eliminar Clientes Fisicamente

DELETE Cliente WHERE Nit='4'

--4. Ingresar Productos al Inventario

SELECT * FROM Inventario


INSERT INTO Inventario VALUES (2,'Salsa','250',5)

--5. Actulizar la cantidad del Producto

UPDATE Inventario SET Cantidad='620' WHERE Producto='1'

--6. Actulizar la cantidad del Producto

UPDATE Inventario SET Nombre='tortillas' WHERE Producto='1'

--7. Ingresar Un factura nueva

SELECT * FROM Factura


INSERT INTO Factura VALUES (1,2,1)

SELECT* FROM Detalle


INSERT INTO Detalle VALUES (1,2,99,250)

SELECT (Detalle.Factura),(Detalle.Producto),(Detalle.Cantidad),(Detalle.Precio),
(Precio*Cantidad)AS TOTAL FROM Detalle
SELECT (Detalle.Factura),(Detalle.Producto),(Detalle.Cantidad),(Detalle.Precio)AS
Precio,(Precio*CANTIDAD)AS TOTAL FROM Detalle
USE [Proyecto]
GO
/****** Object: Table [dbo].[Detalle] Script Date: 03/05/2011 13:02:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Detalle](
[Factura] [int] NOT NULL,
[Producto] [int] NOT NULL,
[Cantidad] [int] NULL,
[Precio] [int] NULL,
CONSTRAINT [PK_Detalle] PRIMARY KEY CLUSTERED
(
[Factura] ASC,
[Producto] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Cliente] Script Date: 03/05/2011 13:02:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Cliente](
[Nit] [int] NOT NULL,
[Nombre] [varchar](50) NULL,
[Direccion] [varchar](50) NULL,
[Telefono] [numeric](18, 0) NULL,
CONSTRAINT [PK_Cliente] PRIMARY KEY CLUSTERED
(
[Nit] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Inventario] Script Date: 03/05/2011 13:02:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Inventario](
[Producto] [int] NOT NULL,
[Nombre] [varchar](50) NULL,
[Cantidad] [numeric](18, 0) NULL,
[Precio] [money] NULL,
CONSTRAINT [PK_Inventario] PRIMARY KEY CLUSTERED
(
[Producto] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Factura] Script Date: 03/05/2011 13:02:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Factura](
[Factura] [int] NOT NULL,
[Nit] [int] NULL,
[Fecha] [int] NULL,
CONSTRAINT [PK_Factura] PRIMARY KEY CLUSTERED
(
[Factura] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: ForeignKey [FK_Factura_Cliente] Script Date: 03/05/2011 13:02:38 ******/
ALTER TABLE [dbo].[Factura] WITH CHECK ADD CONSTRAINT [FK_Factura_Cliente]
FOREIGN KEY([Nit])
REFERENCES [dbo].[Cliente] ([Nit])
GO
ALTER TABLE [dbo].[Factura] CHECK CONSTRAINT [FK_Factura_Cliente]
GO
/****** Object: ForeignKey [FK_Factura_Cliente1] Script Date: 03/05/2011 13:02:38 ******/
ALTER TABLE [dbo].[Factura] WITH CHECK ADD CONSTRAINT [FK_Factura_Cliente1]
FOREIGN KEY([Nit])
REFERENCES [dbo].[Cliente] ([Nit])
GO
ALTER TABLE [dbo].[Factura] CHECK CONSTRAINT [FK_Factura_Cliente1]
GO

You might also like