How do I auto create student id number in mysql? -
i'm new mysql. created table student
.
create table student( studentid int(10) not null, firstname varchar(100) not null, lastname varchar(100) not null, birthday varchar(12) not null, gender varchar(7), course_name varchar(150) not null, primary key(studentid ) );
i thought nice studentid
auto create system. , don't know how this. may simple question guys. please me this.
thanks.
the auto_increment
attribute can used generate unique identity new rows:
ex -
create table animals ( id int not null auto_increment, name char(30) not null, primary key (id) );
when inserting data table don't have input data id
.
insert animals (name) values ('dog'),('cat'),('penguin'), ('lax'),('whale'),('ostrich');
which returns -
+----+---------+ | id | name | +----+---------+ | 1 | dog | | 2 | cat | | 3 | penguin | | 4 | lax | | 5 | whale | | 6 | ostrich | +----+---------+
answer question -
create table student( studentid int(10) not null auto_increment, firstname varchar(100) not null, lastname varchar(100) not null, birthday varchar(12) not null, gender varchar(7), course_name varchar(150) not null, primary key(studentid ) );
for more information refer here.
Comments
Post a Comment