Skip to content

Commit

Permalink
Se agregan tres querys. Para crear la base de datos, para crear la ta…
Browse files Browse the repository at this point in the history
…bla persona e insertar dos registros y las consultas de la parte 1 y 2
  • Loading branch information
SebaLerotich committed May 19, 2023
1 parent 79868e3 commit 7c70eb7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Python/Semana 4/Consultas_Parte1yParte2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--Consulta informacion seleccionada
--SELECT * FROM persona WHERE id_persona IN (1,2,3)
--Ingresamos un nuevo elemento a la tabla
--INSERT INTO persona(nombre,apellido,email) VALUES ('Susana','Lara','slara@mail.com')
--Hacemos la consulta para ver toda la informacion de la tabla
--SELECT * FROM persona
--UPDATE persona SET nombre = 'Ivonne', apellido = 'Esperanza', email = 'iesparza@mail.com' WHERE id_persona = 3
SELECT * FROM persona
--DELETE FROM persona WHERE id_persona = 3
13 changes: 13 additions & 0 deletions Python/Semana 4/Creacion_DataBase.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Database: test_bd

-- DROP DATABASE IF EXISTS test_bd;

CREATE DATABASE test_bd
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'Spanish_Spain.1252'
LC_CTYPE = 'Spanish_Spain.1252'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;
23 changes: 23 additions & 0 deletions Python/Semana 4/Creacion_Tabla_Persona.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- Crea la secuencia
CREATE SEQUENCE IF NOT EXISTS persona_id_persona_seq;

-- Crea la tabla persona
CREATE TABLE IF NOT EXISTS public.persona
(
id_persona integer NOT NULL DEFAULT nextval('persona_id_persona_seq'),
nombre character varying COLLATE pg_catalog."default",
apellido character varying COLLATE pg_catalog."default",
email character varying COLLATE pg_catalog."default",
CONSTRAINT persona_pkey PRIMARY KEY (id_persona)
)
TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.persona
OWNER to postgres;

-- Inserta datos en la tabla persona
INSERT INTO persona(nombre,apellido,email) VALUES ('Susana','Lara','slara@mail.com');
INSERT INTO persona(nombre,apellido,email) VALUES ('Lorena','Gutierrez','lgutierrez@mail.com');

-- Selecciona todas las filas de la tabla persona
SELECT * FROM persona;

0 comments on commit 7c70eb7

Please sign in to comment.