Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

51.

What is the use of CONCAT() in Mysql?

Answer»

It is USED to CONCATENATE TWO or more strings.

Example

SELECT CONCAT('BestInterview', ' ', 'Question') AS 'Name';

52.

List some comparisons operators used in Mysql?

Answer»

Comparisons OPERATORS are used to comparing ONE EXPRESSION to ANOTHER value or expression. It is just LIKE = , < , > , => , =<, <>

53.

What are the difference between NOW and CURRENT_DATE in MySQL?

Answer»
NOWCURRENT_DATE
NOW() GIVE you the current DATE TIME in the FORMAT 'YYYY-MM_DD HH:MM: SS'CURRENT_DATE() will only give you the current date in format "YYYY-MM_DD"
54.

What is TRIGGERS and how it can be used in MySQL?

Answer»

In Mysql, a trigger is a database object that is directly associated with a table. It will be activated when a defined action is executed for the table. It can be PERFORMED when you run ONE of the following MySQL LIKE INSERT, UPDATE and DELETE occurred in a table. It's activation time can be BEFORE or AFTER

Example

mysql&GT; delimiter //

mysql> CREATE TRIGGER age_check BEFORE INSERT ON people FOR EACH ROW IF NEW.age < 0 THEN SET NEW.age = 0; END IF;

mysql> delimiter ;

55.

Explain the difference between primary key and candidate key in Mysql?

Answer»
Primary KeyCANDIDATE Key
It is a column that uniquely identifies a record. In Mysql, only one candidate key can behave LIKE Primary Key.It can be any column that can QUALIFY as a unique key in the database. In MySQL, there can be MULTIPLE candidate KEYS in one table. Each candidate key can behave like as a primary key.
56.

How do I import database through command line?

Answer»

MySQL -u username -p database_name < file.SQL
Here username is your DATABASE username like "ROOT," database_name is your database name, file.sql is your SQL file name with COMPLETE PATH.

57.

What is the default port for MySQL and how it can change?

Answer»

The default port is 3306. We can CHANGE it in /etc/MySQL/my.conf there is a port variable. We can UPDATE this port ACCORDING to our NEED

58.

What is DDL, DML and DCL in MySQL?

Answer»

1. DDL

In MySQL, DDL is the short FORM for Data Definition Language, which is used in DATABASE schemas and descriptions while deciding how data should RESIDE in the database.

Here’s a list of DDL Queries:
  • CREATE
  • ALTER
  • DROP
  • TRUNCATE
  • COMMENT
  • RENAME
2. DML

DML is a short form for Data Manipulation Language which is used in data manipulation and mostly includes common SQL statements to store, modify, retrieve, delete and update data in a database.

Here is the list of DML Queries:
  • SELECT
  • INSERT
  • UPDATE
  • DELETE
  • MERGE
  • CALL
  • EXPLAIN PLAN
  • LOCK TABLE
3. DCL

DCL is a short form for Data Control Language including commands which are concerned with User rights, permissions and other controls within the database system.

Here’s a list of queries for DCL:
  • GRANT
  • REVOKE
59.

What is the difference between the primary and unique key in Mysql?

Answer»
PRIMARY KEYUnique Key
A table can HOLD only one primary keyIt can be more than one unique key in one table
A Primary Key cannot be NULL.A Unique key can have NULL.
60.

How to create case insensitive query in MySQL?

Answer»

The standard way to perform case INSENSITIVE queries in SQL is to use the SQL UPPER or lower functions like the following:

select * from users where upper(first_name) = 'AJAY';

OR

select * from users where lower(first_name) = 'ajay';

The method is to make the FIELD you are searching as uppercase or lowercase then ALSO make the search string uppercase or lowercase as per the SQL function.

Also Read: MongoDB Interview Questions And ANSWERS
61.

What is cardinality in MySQL?

Answer»

In MySQL, the time PERIOD cardinality REFERS to the SPECIALTY of facts VALUES that can be put into columns. It is a type of property that influences the potential to search, cluster and kind data.

Cardinality can be of TWO sorts which are as follows
  • Low Cardinality − All values for a column have to be the same.
  • High Cardinality − All values for a column ought to be unique.
62.

What is indexing and how do you create an index in MySQL?

Answer»

A DATABASE index is the structure of a fact that improves the velocity of operations in a table. It can be created the USAGE of one or greater columns, presenting the FOUNDATION for each fast random lookups and efficient ORDERING of getting admission to records. Indexes are used to locate rows with specific column values quickly.

Example

CREATE INDEX [index name] ON [table name]([column name]);

63.

What are the different ways to optimize a MySQL query?

Answer»
  • Don't USE "sp_" while creating a stored procedure.
  • Don't use "*" while you are USING the SELECT command. Also avoid unnecessary columns in SELECT clause.
  • You can use table aliases while writing queries.
  • Avoid the usage of the wildcard (%) at the starting of a predicate.
  • DISTINCT and UNION NEED to be USED solely if it is necessary.
64.

Is MySQL case-sensitive?

Answer»

Mysql is not CASE sensitive. Its case-SENSITIVITY relies on the UNDERLYING operating system as OS determines the case sensitivity of TABLES names and database. In windows, database and table names are not case sensitive but in the case of UNIX, it is case sensitive in nature. Especially on the UNIX host, database ACCEPTS the upper case and lower-case table names.

65.

What is the difference between delete, drop and truncate?

Answer»

TRUNCATE

  • It removes all rows from a table.
  • It does not require a WHERE clause.
  • Truncate cannot be used with indexed views.
  • It is performance wise faster.
DELETE
  • It removes Some or All rows from a table.
  • A WHERE clause is used to REMOVE particular rows according to the MATCHED condition. All rows will be deleted when we did not use Where condition in Query.
  • It removes rows ONE by at a time.
  • It can be used with indexed views.
DROP
  • It removes a table from the database.
  • All table's rows, indexes, and privileges will also be removed when we used this command.
  • The operation cannot be ROLLED back.
66.

What are the difference between and MyISAM and InnoDB?

Answer»

These are most commonly used storage engine in MySQL are MyISAM and InnoDB.

Difference between MyISAM and InnoDB are given below:-
  • MyISAM does no longer support transactions, however InnoDB supports transactions.
  • MyISAM HELPS Table-level LOCKING, however InnoDB supports Row-level Locking.
  • MyISAM helps full-text search, however InnoDB does not.
  • MyISAM designed for the need for speed but InnoDB designed for most performance.
  • MyISAM does now not aid OVERSEAS keys, but InnoDB helps foreign keys.
  • We can use commit and rollback with InnoDB however not in MyISAM.
  • MyISAM does no longer assist ACID (Atomicity, Consistency, Isolation, and Durability) however InnoDB supports the ACID property.
  • In the InnoDB table, the AUTO_INCREMENT field is a section of the index but now not in MyISAM.
  • MyISAM stores its TABLES, data, and indexes in disk area the usage of a separate table name.FRM, desk name.MYD and table name.MYI however InnoDB stores its tables and indexes in a tablespace.