Medium sql

MySQL CREATE TABLE with AUTO_INCREMENT #45

Problem

MySQL: MySQL CREATE TABLE with AUTO_INCREMENT #45

Hints
  • Use MySQL docs syntax for LIMIT and functions

Your solution

TestStatusDetails
Ready — edit the code above and click Run or Submit.

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.

Discussion

0

Sign in to join the discussion.

No discussions yet — ask the first question!

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