We want to make a table with these values from the example
The values must correspond to the values types decalred in the table.
CREATE TABLE student( student_id INT, name VARCHAR(20), major VARCHAR(20), PRIMARY KEY(student_id) ); INSERT INTO student VALUES(1,'Jack','Biology');
If inserted, you will see Rows affected: 1
To display the table with values use SELECT
followed by the
*
asterisk then FROM <tablename>
SELECT * FROM student;
The SELECT * FROM
keywords display tables with values, while DESCRIBE
show just the table
Add more values the same way. Since the student_id
column is the PRIMARY KEY
it cannot be repeated.
INSERT INTO student VALUES(2,'Kate','Sociology');
If you try to run the same line,
INSERT INTO student VALUES(2,'Kate','Sociology');
It will throw an error