Data Insert
→ INSERT INTO cats(name, age) VALUES('Juwon', 7), ("Seyeon", 8);
Indicate all data from table
→ SELCET * FROM cats;
Disallow NULL data from the table field
[ If the name and age fields are not populated when entering data, an error will occur. ]
→ CREATE TABLE cats (
name VARCHAR(100) NOT NULL,
age INT NOT NULL
);
Insert a small apostrophe into the table data.
→ INSERT INTO cats (name) VALUES ('Juwon\'s chicken');
Set a default value for the table field.
→ CREATE TABLE cats (
name VARCHAR(50) DEFAULT 'mystery',
age INT DEFAULT 99
);
Automatically insert a key value into the table field.
[The key value is unique.]
→ CREATE TABLE cats (
cat_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50),
age INT
);
'Database' 카테고리의 다른 글
SQL_Read, Update, Delete (0) | 2024.08.23 |
---|---|
SQL_Creating databases and tables (0) | 2024.04.01 |