Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. -- Creating a table named students
  2. -- Making student_id the PRIMARY KEY and Auto_Inrementing it on each new entry
  3. -- Giving the 'major' row a DEFAULT VALUE if NULL
  4.  
  5. CREATE TABLE students (
  6. student_id INT PRIMARY KEY AUTO_INCREMENT,
  7. name VARCHAR (20),
  8. major VARCHAR (20) DEFAULT 'Undecided'
  9. );
  10.  
  11. SELECT * FROM students;
  12.  
  13. // Inserting values into the table without inserting the student_id (which will be filled in by the program itself)
  14. INSERT INTO students(name, major) VALUES ('Jack', 'Biology');
  15. INSERT INTO students(name, major) VALUES ('Kate', 'Sociology');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement