Skip to content

Instantly share code, notes, and snippets.

@Mrvishal2k2
Last active September 29, 2022 09:29
Show Gist options
  • Select an option

  • Save Mrvishal2k2/cd9b6f241d0c79bf4ad03743c4ba9c0d to your computer and use it in GitHub Desktop.

Select an option

Save Mrvishal2k2/cd9b6f241d0c79bf4ad03743c4ba9c0d to your computer and use it in GitHub Desktop.
Some basic of mysqli commandline
#THEBASE
1.create a table employee with attributes empid, name, dob, gender, address, zipcode. The attributw empid is a unique value given to all employee. Make sure no sttributes allow null values
create database newdb;
use newdb;
create table employee(
empid int not null primary key,
name varchar(50) not null,
dob date not null,
gender varchar(8) not null,
address varchar(255) not null,
zipcode int not null
);
desc employee;
task 2
2. Insert atleast 5 rows in the table
insert into employee values(1,'User1','2022-06-17','Male','China1',561230);
insert into employee values(2,'User2','2022-06-18','Female','China2',561230);
insert into employee values(3,'User3','2022-06-19','Male','China3',561230);
insert into employee values(4,'User4','2022-06-20','Female','China4',561230);
insert into employee values(5,'User5','2022-06-21','Male','China5',561230);
3. Display the records in employee table
select * from employee;
task3
4. Add a new fields contact number and supervisor in th employee tables
alter table employee
add contact_no int not null,
add supervisor varchar(20) not null;
insert into employee values(6,'User6','2022-06-22','Female','INDIA',560096,123456789,'true');
task 5
5. Modify the size of the name
alter table employee
modify name varchar(100) not null;
task 6
6. CHange the attribute name zipcode with pincode
alter table employee
rename column zipcode to pincode;
7. Update the values of the contact number and supervisor
update employee
set contact_no = 45612354 where empid=6;
update employee
set supervisor = 'nope' where empid=6;
desc employee;
select * from employee;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment