Hard sql

MySQL CREATE TABLE with AUTO_INCREMENT #22

Problem

MySQL: MySQL CREATE TABLE with AUTO_INCREMENT #22

Hints
  • Use MySQL docs syntax for LIMIT and functions

Your practice code

Ready — edit the code above and click Run.

Solution

CREATE TABLE orders (
  id INT AUTO_INCREMENT PRIMARY KEY,
  customer_id INT NOT NULL,
  amount DECIMAL(12,2) NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  CONSTRAINT fk_customer FOREIGN KEY (customer_id) REFERENCES customers(id)
) ENGINE=InnoDB;

Try solving on your own first, then reveal the official answer.

Explanation

MySQL-specific syntax: LIMIT, AUTO_INCREMENT, ENGINE=InnoDB, DELIMITER for procedures.

Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details