Introduction
Sometimes you want to add a new row to a table and use the default values set for some or all columns. This saves time and keeps data consistent.
INSERT INTO table_name DEFAULT VALUES;
INSERT INTO employees DEFAULT VALUES;
INSERT INTO orders (order_date, status) VALUES (DEFAULT, DEFAULT);
CREATE TABLE products ( id SERIAL PRIMARY KEY, name VARCHAR(50) DEFAULT 'Unknown', price NUMERIC DEFAULT 0.0 ); INSERT INTO products DEFAULT VALUES; SELECT * FROM products;
INSERT INTO table_name DEFAULT VALUES; do?INSERT INTO table_name DEFAULT VALUES; to insert a row with all default values.users(id INT DEFAULT 0, name VARCHAR(20) DEFAULT 'guest'), what will be the result of INSERT INTO users DEFAULT VALUES; SELECT * FROM users; after running on an empty table?products(id INT NOT NULL, name VARCHAR(20) DEFAULT 'unknown'). What error occurs when running INSERT INTO products DEFAULT VALUES;?orders(order_id INT PRIMARY KEY DEFAULT nextval('order_seq'), status VARCHAR(10) DEFAULT 'pending', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP). Which SQL statement correctly inserts a new order using all defaults except setting status to 'shipped'?Pass the test and this pattern moves unknown