Lets say we have a simple table within our db for students. This would be created as follows:
CREATE TABLE student(
id INT PRIMARY KEY,
name VARCHAR(20),
email VARCHAR(30) DEFAULT 'no email',
major VARCHAR(20)
);
Now the table has been created we need to insert data into it. We do that as follows:
INSERT INTO student VALUES(1, 'Paul Bennett', '[email protected]', 'SQL Databases');
Let me break down what's in the value ()
- 1 = id
- Paul Bennett = name
- [email protected] = email
- SQL Databases = major
We insert the data in the order of the columns.