Home > Mobile >  MySQL: Created Table won't show values?
MySQL: Created Table won't show values?

Time:10-28

I'm new to MySQL and I created a table called students with some attributes but when I run Select * From Students it appears as null for each category I'm not sure why

use  practice;

create table Students(
    sid     integer  default 1,
    sname   varchar(50)  default 'Joe',
    GPA     real         default 1.7,
    dateOfBirth date     default (2000-12-12),
    primary key(sid)
);

select *
from Students

CodePudding user response:

You can try to insert a value in your table (Insert into Students ('sid', 'sname', 'GPA', 'dateOfBirth') Values ('NULL', 'joe', '1.7', '200-12-12'); this will solve your problem with the SELECT *
I would also add an auto increment on your sid so you can putt the value of sid to null and it will automatically ALTER TABLE Students MODIFY 'sid' INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY;

  • Related