mysql create table primary key
snippet in sql

alter table add foreign key mysql

user7128

ALTER TABLE Orders
ADD 
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID) ON DELETE CASCADE; 

create table mysql query

user3433

create table tutorials_tbl(
   tutorial_id INT NOT NULL AUTO_INCREMENT,
   tutorial_title VARCHAR(100) NOT NULL,
   tutorial_author VARCHAR(40) NOT NULL,
   submission_date DATE,
   PRIMARY KEY ( tutorial_id )
);

create table in mysql

user5649

# Creates a Simple User table
# Uses an auto-incrementing primary key as userId 

CREATE TABLE user (
    userId INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(100),
    password VARCHAR(100) 
) ENGINE=InnoDB;

mysql change primary key

user6863

ALTER TABLE tableName MODIFY COLUMN id INT; /* First you should drop auto increment */
ALTER TABLE tableName DROP PRIMARY KEY; /* Dop primary key */
ALTER TABLE tableName ADD PRIMARY KEY (new_id); /* Set primary key to the new column */
ALTER TABLE tableName MODIFY COLUMN new_id INT AUTO_INCREMENT; /* Set auto increment to the new primary key */

create a table in sql with primary key

user6178


CREATE TABLE table_name
(
   Column1 datatype,		// column1 and datatype
   Column2 datatype,		// column2 and datatype
   Column3 datatype,		// column3 and datatype
  
   PRIMARY KEY (Column1);	// column1 is the primary key
); 

mysql create table primary key

user4698


CREATE TABLE Persons
(

    ID int NOT NULL,

   
LastName varchar(255) NOT NULL,

   
FirstName varchar(255),

   
Age int,

   
PRIMARY KEY (ID)

);