Skip to content

Instantly share code, notes, and snippets.

@pazteddy
Last active February 23, 2026 19:26
Show Gist options
  • Select an option

  • Save pazteddy/ec650378caecce78cb0450a56f5aabb4 to your computer and use it in GitHub Desktop.

Select an option

Save pazteddy/ec650378caecce78cb0450a56f5aabb4 to your computer and use it in GitHub Desktop.
Creación de base datos, tabla para productos y datos iniciales
-- Creación de base de datos
CREATE DATABASE products_api
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
-- Usar nuestro base de datos products_api
USE products_api;
-- Tabla para productos
CREATE TABLE products (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(150) NOT NULL,
price DECIMAL(10,2) NOT NULL,
stock INT UNSIGNED NOT NULL DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Inserción datos de prueba
INSERT INTO products (name, price, stock)
VALUES
('Laptop', 1200.00, 3),
('Mouse', 25.00, 15);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment