Drop command to remove a column from a table.

suppose we have a column address in table employee.

To see the description of table we use desc employee that will produce following result here we can see the description of table.

if we want to eliminate the column address from employee table then we use Drop command. Syntax:

Drop query

Read more

Date and Time

There are various pre defined function for data and time we will see them one by one. If you want to show current time then we use CURTIME().It returns time in HH:MM:SS string format

below is HHMMSS in numeric format

To select current data we use CURDATE().It returns data in YYYY-MM-DD string format. … Read more

creating a new user in mysql

Here we are creating user with name manish and password for manish is password;

Creating a user and force user to change password at first login for that PASSWORD EXPIRE is used.

Creating a user and expiring the password after 180 days, PASSWORD EXPIRE INTERVAL 180 DAY is used

Creating a user … Read more

Changing primary key of table

We have a table basic profile with following table structure

we don’t want to use it as primary key so first we removed its auto increment the we will remove it from primary key queries for these are

If you want to make primary key to some other column than we can … Read more

Alter table command to add foreign key

We have two tables company and location. First table manages company details and second table stores location detail of company. one company can span in multiple location. Initially we have created table for company and location as below.

checking the description of both table

Now We find that one company can … Read more

Drop foreign key constraints

Some times we have to drop the foreign key constraint that already exists, for that we have to first get the foreign key constraint name. To see detailed description of created table we use following query.

Result of above query is

Here we can see that company_id column is referring company tables id … Read more

Show engine innodb status

InnoDB Monitors provide information about the InnoDB internal state. This information is useful for performance tuning. Each Monitor can be enabled by creating a table with a special name, which causes InnoDB to write Monitor output periodically. Also, output for the standard InnoDB Monitor is available on demand through the SHOW ENGINE INNODB STATUS SQL … Read more

updating user login password

SET PASSWORD FOR ‘user’@’localhost’ = PASSWORD( ‘NewPassword’ ); SHOW VARIABLES LIKE ‘validate_password%’; # SET GLOBAL validate_password_length = 5; # SET GLOBAL validate_password_number_count = 0; # SET GLOBAL validate_password_mixed_case_count = 0; # SET GLOBAL validate_password_special_char_count = 0;

Updating the column data size

To create a table

after creating table we want to increase the size of description field from varchar(20) to varchar(100). for that we will use alter table command Syntax

Example

we can also decrease the size of column but it may cause the data loss. like

Insertion of a new record in a table

To insert a new record in a table we use Insert Query. Syntax: To insert all fields value in table we use following insert query

To insert all or selected fields value in table we use following insert query

We have created a table student as below

To insert record in above … Read more