create a table with an id in mysql 1

create a table with an id in mysql

CREATE TABLE DemoT (
    Personid int NOT NULL AUTO_INCREMENT,
    LastName varchar(111) NOT NULL,
    FirstName varchar(111),
    Age int,
    PRIMARY KEY (Personid)
);

Here is what the above code is Doing:
1. We’re creating a table called DemoT.
2. We’re creating a column called Personid, which is an integer, and it’s the primary key.
3. We’re creating a column called LastName, which is a varchar, and it can’t be null.
4. We’re creating a column called FirstName, which is a varchar, and it can be null.
5. We’re creating a column called Age, which is an integer, and it can be null.

Similar Posts