Last active
February 23, 2026 19:26
-
-
Save pazteddy/ec650378caecce78cb0450a56f5aabb4 to your computer and use it in GitHub Desktop.
Creación de base datos, tabla para productos y datos iniciales
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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