Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Creating a table named students
- -- Making student_id the PRIMARY KEY and Auto_Inrementing it on each new entry
- -- Giving the 'major' row a DEFAULT VALUE if NULL
- CREATE TABLE students (
- student_id INT PRIMARY KEY AUTO_INCREMENT,
- name VARCHAR (20),
- major VARCHAR (20) DEFAULT 'Undecided'
- );
- SELECT * FROM students;
- // Inserting values into the table without inserting the student_id (which will be filled in by the program itself)
- INSERT INTO students(name, major) VALUES ('Jack', 'Biology');
- INSERT INTO students(name, major) VALUES ('Kate', 'Sociology');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement