Table of Contents
The top SQL interview questions are listed here. The comprehensive responses offered in this article will not only assist you in your interviews but will also equip you with a fundamental comprehension of many SQL and MySQL-related issues. This post will give you the 100 most typical SQL and MySQL interview questions to help you prepare for a SQL interview. This blog includes both fundamental and sophisticated SQL interview questions that might be asked of both inexperienced and experienced candidates. One of the key computer languages for interacting with different database systems is SQL. It is crucial to the data collection and analysis process. SQL proficiency is necessary for many different job roles, including data analysts, database administrators, and data architects. Both technical and non-technical people must possess this ability.
Power up your career with Entri Elevate – Full Stack Development Course!
Basic Level SQL Interview Questions 2024
Q1. What is DBMS?
1: Which of the following data structures allows elements to be added and removed in a Last-In, First-Out (LIFO) order?
The system software used to create and manage databases is referred to as a database management system (DBMS). In order to keep data consistently organized and accessible, it acts as an interface between databases and users or application programs. It enables database end users to create, read, edit, and delete data. Two categories of DBMS exist:
RDBMS stands for Relational Database Management System, which stores data in relationships (tables). MySQL is an example. NoSQL databases, sometimes known as non-relational database management systems, include: It keeps information in a non-tabular format. Consider MongoDB.
Q2. What is SQL?
A database can be created, updated, and modified using the computer language SQL (structured querying language). It serves as the Relational Database System standard language. Being the industry standard database language, SQL is used by every RDMS including MySQL, MS Access, Oracle, and SQL Server.
Q3. What is MySQL?
The relational database management system (RDBMS) MySQL is an open-source RDBMS created and offered by Oracle Corporation. MySQL is compatible with a wide range of operating systems, including Windows, Unix, Linux, etc. It may be used to create a variety of applications. Often used for creating web applications, MySQL is renowned for its quickness, dependability, and versatility.
Q4. What are the subsets of SQL? Explain them.
The following are the three subsets of SQL:
- Data Definition Language (DDL) – It allows end-users to CREATE, ALTER, and DELETE database objects.
- Data Manipulation Language (DML) – With this, you can access and manipulate data. It allows you to Insert, Update, Delete, and Retrieve data from the database.
- Data Control Language (DCL) – This lets you control access to the database. It includes the Grant and Revoking permissions to manipulate or modify the database.
Q5. What is the primary key?
Each row or record in a database table is uniquely identified by a primary key constraint. Unique values must be present in primary keys. The primary key column does not accept null values or duplicate values. There can only be one primary key per table. It could include one or more fields.
Q6. What is a foreign key?
Two tables are connected via a foreign key, also known as the reference key. It consists of a column or group of columns whose values coincide with a primary key in another table. Because it uses the primary key of another table to make a connection between them, it functions as a cross-reference between tables.
Q7. What is RDBMS?
One of the most well-known database management systems is Relational Database Management System, or RDBMS, which is based on the relational database concept.
Q8. What are the features of MySQL?
- It is reliable and easy to use
- It supports standard SQL (Structured Query Language)
- MySQL is secure as it consists of a data security layer that protects sensitive data from unauthorized users
- MySQL has a flexible structure and supports a large number of embedded applications
- It is one of the very fast database languages
- It is a suitable database software for both large and small applications
- MySQL offers very high-performance results compared to other databases
- It is supported by many well-known programming languages, such as PHP, Java, and C++
- It is free to download and use
Are you aspiring for a booming career in IT? If YES, then dive in |
||
Full Stack Developer Course |
Python Programming Course |
Data Science and Machine Learning Course |
Q9. What are the disadvantages of MySQL?
- It is hard to make MySQL scalable
- It does not support a very large database size as efficiently
- MySQL does not support SQL check constraint
- It is prone to data corruption
Q10. What are the differences between MySQL vs SQL?
MySQL | SQL |
1. It is a relational database that uses SQL to query a database | 1. It is a query language |
2. MySQL supports multiple storage engines and plug-in storage engines | 2. SQL supports a single storage engine |
3. It is a database that stores the existing data in a database in an organized manner. | 3. SQL is used to access, update, and manipulate the data stored in a database |
4. Supports many platforms | 4. Supports only Linux and Windows |
5. It has a complex syntax | 5. It has a simpler syntax |
Q11. What is a unique key?
A set of one or more table fields or columns known as a unique key is used to identify a record in a database table. A particular kind of unique key is a primary key.
Experience the power of our web development course with a free demo – enroll now!
Q12. Explain the different types of indexes in SQL.
There are three types of indexes in SQL:
- Unique Index – It does not allow a field to have duplicate values if the column is unique indexed.
- Clustered Index – This index defines the order in which data is physically stored in a table. It reorders the physical order of the table and searches based on key values. There can be only one clustered index per table.
- Non-Clustered Index – It does not sort the physical order of the table and maintains a logical order of the data. Each table can have more than one non-clustered index.
Q13. What is the difference between TRUNCATE and DELETE?
DELETE | TRUNCATE |
Delete command is used to delete a specified row in a table. | Truncate is used to delete all the rows from a table. |
You can roll back data after using the delete statement. | You cannot roll back data. |
It is a DML command. | It is a DDL command. |
It is slower than a truncate statement. | It is faster. |
Q14. What is the difference between:
SELECT * FROM MyTable WHERE MyColumn <> NULL
SELECT * FROM MyTable WHERE MyColumn IS NULL
Because you cannot use scalar value operators with NULL, which stands for “no value,” the first syntax will not function. Because of this, SQL has a distinct IS-a NULL predicate.
Q15. What is the difference between CHAR and VARCHAR?
The character data types CHAR and VARCHAR both have fixed lengths for characters.
Q16. What is a subquery in SQL? What are the different types of subquery?
An internal query is known as a subquery. When a query is contained within another query, the outer query is referred to as the main query and the inner query as a subquery. A subquery can be of two types:
Correlated subquery: Before it executes, it retrieves values from its outer query. The outer query receives the results from the subquery after it has finished running.
Unrelated subquery: It runs separately from the main query. The outer query receives the results of the subquery’s execution before continuing. You can perform inner and outer queries independently.
Q17. What is collation sensitivity?
Among other criteria, accurate character order, case sensitivity, character width, and accent marks are taken into account while defining the rules for sorting and comparing character data strings.
Q18. What are the different types of collation sensitivity?
- Accent sensitivity
- Case sensitivity
- Kana sensitivity
- Width sensitivity
Q19. What is a “scheduled job” or “scheduled task”?
Automated task management on regular or predictable cycles is possible with scheduled jobs or tasks. Administrative chores can be scheduled, and their priority can be chosen.
Q20. Can you name different types of MySQL commands?
- Data Definition Language (DDL)
- Data Manipulation Language (DML)
- Data Control Language (DCL)
- Transaction Control Language (TCL)
Get hands-on with our data science and machine learning course – sign up for a free demo!
Q21. Explain different DDL commands in MySQL.
- CREATE – Used to create the database or its objects like table, index, function, views, triggers, etc.
- DROP – Used to delete objects
- ALTER – Used to change database structures
- TRUNCATE – It erases all records from a table, excluding its database structure
- COMMENT – Used to add comments to the data dictionary
- RENAME – Used to rename a database object
Q22. Explain different DML commands in MySQL.
- SELECT – Used to select specific database data
- INSERT – Used to insert new records into a table
- UPDATE – It helps in updating existing records
- DELETE – Used to delete existing records from a table
- MERGE – Used to UPSERT operation (insert or update)
- CALL – It is used when you need to call a PL/SQL or Java subprogram
- EXPLAIN PLAN – Used to interpret data access path
- LOCK TABLE – Used to control concurrency
Q23. Explain different DCL commands in MySQL.
- GRANT – It provides user access privileges to the database
- DENY – Used to deny permissions to users
- REVOKE – Used to withdraw user access by using the GRANT command
Q24. Explain different TCL commands in MySQL.
- COMMIT – Used to commit a transaction
- ROLLBACK – Used to roll back a transaction
- SAVEPOINT – Used to roll back the transaction within groups
- SET TRANSACTION – Used to specify transaction characteristics
Q25. What are the different types of Database relationships in MySQL?
- One-to-one – Both tables can have only one record
- One-to-many – The single record in the first table can be related to one or more records in the second table
- Many-to-many – Each record in both the tables can be related to any number of records
Q26. What is Normalization?
Tables are organized using the database design method known as normalization to lessen data reliance and redundancy.
Q27. What are the different types of Normalization?
- First Normal Form (1NF)
- Second Normal Form (2NF)
- Third Normal Form (3NF)
- Boyce-Codd Normal Form (BCNF)
- Fourth Normal Form (4NF)
- Fifth Normal Form (5NF)
Q28. What is Denormalization?
By adding redundant data to one or more tables, denormalization is a database optimization technique for improving database infrastructure performance.
Q29. Is MySQL query case-sensitive?
MySQL queries are not case-sensitive by default. The following queries are the same.
SELECT * FROM `table` WHERE `column` = ‘value’
SELECT * FROM `table` WHERE `column` = ‘VALUE’
SELECT * FROM `table` WHERE `column` = ‘VaLuE’
Q30. How many TRIGGERS are allowed in the MySQL table?
6 triggers are allowed in the MySQL table:
- BEFORE INSERT
- AFTER INSERT
- BEFORE UPDATE
- AFTER UPDATE
- BEFORE DELETE
- AFTER DELETE
Power up your career with Entri Elevate – Full Stack Development Course!
Q31. What are the different column comparison operators in MySQL?
The =, <>, <=, <, >=, >, <<, >>, < = >, AND, OR or LIKE operator are the comparison operators in MySQL.
Comparisons operators are generally used with SELECT statements. They are used to compare one expression to another value or expression.
Q32. What syntax can we use to get a version of MySQL?
By using the given query in your phpmyadmin-
SELECT version();
Q33. What is Auto Increment in SQL?
Every time a new record is added to a database, auto increment enables the generation of a distinct number. Typically, we want the PRIMARY KEY field to be automatically produced each time a new record is put.
Q34. SQL Server runs in which TCP/IP port? Can it be changed?
SQL Server runs on port 1433, and it can be changed from the Network Utility TCP/IP properties.
Q35. Name symmetric key encryption algorithms supported in the SQL server.
SQL Server supports several symmetric key encryption algorithms, such as DES, Triple DES, RC2, RC4, 128-bit RC4, DESX, 128-bit AES, 192-bit AES, and 256-bit AES.
crack your career with full stack developer course online !
Q36. What is Database Relationship?
A Database Relationship is defined as the connection between two relational database tables. The primary table has a foreign key that references the primary key of another table. There are three types of Database Relationship –
- One-to-one
- One-to-many
- Many-to-many
Q37. What is faster between a table variable and a temporary table?
A temporary table is stored on disk, however a table variable is typically faster because it is maintained in memory. Both tables function similarly when the size of the table variable exceeds the available memory.
Q38. Mention the command used to get back the privileges offered by the GRANT command?
REVOKE command is used to get back the privileges offered by the GRANT command.
Q39. What is a Clause in SQL?
An SQL clause is a component of a query that enables users to filter or personalize how their data is accessed. By adding a condition to the query, users can restrict the result set. Clause can be used to query and retrieve the user-required data when there is a lot of data stored in the database. The clause function speeds up data filtering and analysis.
WHERE and HAVING clauses are two examples.
Q40. Explain the ‘WHERE’ Clause and the ‘HAVING’ Clause.
It is one of the most important SQL interview questions.
The WHERE clause is used to filter the records from the table or used while joining more than one table. It returns the particular value from the table if the specified condition in the WHERE clause is satisfied. It is used with SELECT, INSERT, UPDATE, and DELETE queries to filter data from the table or relation.
For Example:
SELECT * FROM employees
WHERE working_hour > 9;
The HAVING clause is used to filter the records from the groups based on the given condition in the HAVING Clause. It can only be used with the SELECT statement. It returns only those values from the groups in the final result that fulfills certain conditions.
For Example:
SELECT name, SUM(working_hour) AS “Total working hours”
FROM employees GROUP BY name
HAVING SUM(working_hour) > 6;
Q41. Explain the SELECT statement?
The SQL SELECT statement facilitates database data selection. A result set of records from one or more tables is returned.
Syntax:
SELECT * FROM workers in myDB;
crack your career with full stack developer course online !
Q42. What are the differences between the ‘WHERE’ Clause and the ‘HAVING’ Clause?
WHERE Clause | HAVING Clause |
It performs filtration on individual rows based on the specified condition. | HAVING clause performs filtration on groups based on the specified condition. |
It can be used without GROUP BY Clause. | It is always used with the GROUP BY Clause. |
WHERE Clause is applied in row operations. | HAVING is applied in column operations. |
We cannot use the WHERE clause with aggregate functions. | This clause works with aggregate functions. |
WHERE comes before GROUP BY | HAVING comes after GROUP BY. |
This clause acts as a pre-filter. | HAVING clause acts as a post-filter. |
WHERE Clause can be used with SELECT, INSERT, UPDATE, and DELETE statements. | This Clause can only be used with the SELECT statement. |
Q43. How to find:
duplicate records with one field?
duplicate records with more than one field?
Finding duplicate records with one field:
SELECT COUNT(field)
FROM table_name
GROUP BY field
HAVING COUNT(field) > 1
Finding duplicate records with more than one field:
SELECT field1,field2,field3, COUNT(*)
FROM table_name
GROUP BY field1,field2,field3
HAVING COUNT(*) > 1
Q44. What is a constraint, and how many levels of constraints are there?
Constraints are the representation of a column to enforce data entity and consistency. There are two levels of constraint –
- Column level – Limits only column data
- Table level – Limits whole table data
Following are the most used constraints that can be applied to a table:
- NOT NULL
- UNIQUE
- CHECK
- DEFAULT
- PRIMARY KEY
- FOREIGN KEY
Q45. What are the authentication modes in SQL Server?
The SQL SELECT statement facilitates database data selection. fSQL Server provides two authentication modes and returns a result set of records.
Default Windows Mode. This SQL Server security model is compatible with Windows Mixed Mode and supports SQL Server and Windows authentication.
By choosing the tools option from the SQL Server configuration options, we may switch between modes by hovering over the security page.
from a table or tables.
Syntax:
SELECT * FROM workers in myDB;
Q46. What is PL/SQL?
Procedural Language for SQL, or PL/SQL, was created by Oracle. It allows programmers to write code in a procedural format and is an extension of SQL. The resilience, security, and portability of the Oracle Database are properties shared by both PL/SQL and SQL, which are both executed within the same server process.
Q47. What is SQL Profiler?
SQL Server Profiler is a graphical user interface for creating and saving data on each event of a file. As an issue is being identified, it also enables a system administrator to examine and playback trace results. Uses for SQL Server Profiler include:
Analyze the problematic queries to determine what is causing the issue.
Identify slow-moving queries
Identify the Transact-SQL statements that lead to a problem
Monitor the SQL Server’s performance.
Connect performance counters to identify issues
Q48. What is the SQL Server Agent?
A Microsoft Windows service called SQL Server Agent carries out the regular duties or tasks of a SQL Server Database Administrator (DBA). This service makes it possible to carry out actions at a specified time and date.
Q49. What is Data Integrity?
The accuracy, consistency, and comprehensiveness of the data in a database are qualities of data integrity. It also describes the protection and security of data, which is upheld by a set of procedures, guidelines, and standards that were put in place during the design stage. There are three forms of data integrity:
Column Stability
Object Integrity
Reference Consistency
Q50. What is the difference between Rename and Alias?
Rename is actually changing the name of an object. Alias is giving another name (additional name) to an existing object. Rename involves changing the name of a database object and giving it a permanent name whereas Alias is a temporary name given to a database object.
Syntax of a table Alias:
SELECT column1, column2….
FROM table_name AS alias_name
WHERE [condition];
Syntax of a table Rename:
RENAME TABLE {tbl_name} TO {new_tbl_name};
Power up your career with Entri Elevate – Full Stack Development Course!
Q51. Which are the main steps in Data Modeling?
The following are the main steps in Data Modeling:
- Identify and analyze business requirement
- Create a quality conceptual and logical data model
- Select the target database to create scripts for physical schema using a data modeling tool
Q52. What is Referential Integrity?
Referential integrity is a relational database concept that states that primary and foreign keys should be kept consistent and accurate.
Q53. What is Business Intelligence?
Technologies and methods for gathering, integrating, analyzing, and presenting corporate information are included in business intelligence (BI). It includes best practices, data tools and infrastructure, data mining, data visualization, and business analytics.
Q54. Mention the types of privileges available in SQL?
The sorts of privileges used in SQL are as follows:
System Privilege: This refers to a specific sort of object and denotes actions on it, such as admin, which enables users to conduct administration duties, change any cache group, and change any index.
The ability to do operations on an object using commands like table, view, and indexes is known as object privilege. The SQL commands EXECUTE, INSERT, SELECT, FLUSH, LOAD, INDEX, UPDATE, DELETE, REFERENCES, and others use additional object rights.
Q55. What is the difference between a clustered and non-clustered index?
Clustered Index – A clustered index is used to order the rows in a table. It has leaf nodes consisting of data pages. A table can possess only one clustered index.
Non-clustered Index – A non-clustered index stores the data and indices at different places. It also has leaf nodes that contain index rows. A table can possess numerous non-clustered indexes.
Q56. What is ERD?
ERD or Entity Relationship Diagram is a visual representation of the database structures and shows a relationship between the tables. The ER Diagrams have three basic elements:
- Entities – An entity is a person, place, thing, or event for which data is collected.
- Attributes – It refers to the data we want to collect for an entity. It is a property, trait, or characteristic of an entity, relationship, or another attribute.
- Relationships – It describes how entities interact.
Q57. How will you find the unique values, if a value in the column is repeatable?
To find the unique values when the value in the column is repeatable, we can use DISTINCT in the query, such as:
SELECT DISTINCT user_firstname FROM users;
We can also ask for several distinct values by using:
SELECT COUNT (DISTINCT user_firstname) FROM users;
crack your career with full stack developer course online !
Q58. Explain database white box testing.
White Box Testing is concerned with the internal structure of the database. The users are unaware of the specification details.
- Database white box testing includes testing of database triggers and logical views that support database refactoring.
- Validates database tables, data models, database schema
- Performs module testing of database functions and SQL queries
- Select default table values to check on database consistency
- Adheres to referential integrity rules
Q59. Exhibit the students who are having the same batch ID and study in the same department as student ids, 1002 and 1004.
select x.student_id ,
x.department_id
from students x
where (department_id, batch_id)
in (Select department_id , batch_id
from students
where student_id in (1002,1004))
and x.student_id not in (1002, 1004)
Q60. What is the ACID property in SQL?
ACID is short for Atomicity, Consistency, Isolation, Durability. It ensures Data Integrity during a transaction.
Atomicity: It means either all the operations (insert, update, delete) inside a transaction take place or none. So, if one part of any transaction fails, the entire transaction fails and the database state is left unchanged.
Consistency: Consistency ensures that the data must meet all the validation rules. Irrespective of whatever happens in the middle of the transaction, Consistency property will never leave your database in a half-completed state.
Isolation: It means that every transaction is individual. One transaction can’t access the result of other transactions until the transaction is completed.
Durability: It suggests that keeping track of revisions to committed transactions is crucial. Never let these updates be lost. If either the system or the storage medium fails, it refers to the system’s capacity to recover committed transaction modifications.
Power up your career with Entri Elevate – Full Stack Development Course!
Q61. Explain string functions in SQL?
SQL string functions are used for string manipulation.
Following are the extensively used SQL string functions:
- UPPER(): Converts character data to upper case
- LOWER(): Converts character data to lower case
- SUBSTRING() : Extracts characters from a text field
- RTRIM(): Removes all whitespace at the end of the string
- LEN(): Returns the length of the value in a text field
- REPLACE(): Updates the content of a string.
- LTRIM(): Removes all whitespace from the beginning of the string
- CONCAT(): Concatenates function combines multiple character strings
Q62. What are the differences between the Primary key and the Unique key?
Primary Key | Unique Key |
Enforces column uniqueness in a table | Determines a row that isn’t a primary key |
Does not allow NULL values | Accepts one NULL value |
Has only one primary key | Has more than one unique key |
Creates clustered index | Creates non-clustered index |
Primary Key on CREATE TABLE Syntax: CREATE TABLE Students ( ID int NOT NULL PRIMARY KEY, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int); | Unique Key on CREATE TABLE Syntax: CREATE TABLE Students ( ID int NOT NULL UNIQUE, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int); |
Q63. Write the SQL query to convert the string to UPPERCASE and LOWERCASE.
The SQL query used to convert the string to UPPERCASE and LOWERCASE is:
STRING UPPER(“naukrilearning”); => NAUKRILEARNING
STRING LOWER(“LEARNERS”); => learners
Q64. What is the procedure to hide a specific table name of the schema?
By using SYNONYMS, we can hide a specific table name of the schema.
Syntax:
CREATE SYNONYM STU for STUDENTS;
After creating the above synonym, we can access the data of the STUDENTS table using STU as the table name below
SELECT * from STU;
Q65. What is the syntax to eliminate duplicate rows?
By using the DISTINCT keyword, we can eliminate duplicate records.
Syntax:
SELECT DISTINCT CLASS_ID
FROM STUDENTS;
Q66. Find out nth highest salary from emp table?
Syntax:
select salary from
(select salary, rownum EP from
(select salary from employees
order by salary desc))
where EP=n;
Q67. Name the encryption mechanisms in the SQL server.
This is one of the most popular SQL interview questions. The encryption mechanism used in SQL servers are –
- Transact-SQL functions – Individual items can be encrypted as they are inserted or updated using Transact-SQL functions.
- Asymmetric keys – It is made up of a private key and the corresponding public key. Each key can decrypt data encrypted by the other.
- Symmetric keys – It is used for both encryption and decryption.
- Certificates – Also known as a public key certificate, it binds the value of a public key to the identity of the person, device, or service that holds the corresponding private key.
- Transparent Data Encryption – It is a special case of encryption using a symmetric key that encrypts an entire database using that symmetric key.
Q68. What is the procedure to pass variables in a SQL routine?
Variables can be passed to a SQL routine by using:
- “&” symbol
- SQLPLUS command
Q69. Can a view be updated/inserted/deleted? If yes, at what conditions?
It is not possible to add the data through a view if the view contains the following:
- Group by clause
- Group functions
- DISTINCT keyword
- Columns defined by expressions
- Pseudo column ROWNUM keyword
- NOT NULL column in the base table that is not selected by the view.
Q70. How can you create an SQL table from another table without copying any values from the old table?
Syntax:
CREATE TABLE new_table
AS (SELECT *
FROM old_table WHERE 1=2);
This will create a new table with the same structure as the old table with no rows copied.
Experience the power of our web development course with a free demo – enroll now!
Q71. Explain what is an inline view?
An inline view is a SELECT statement in the FROM-clause of another SELECT statement. In-line views are used to reduce complex queries by removing join operations and summarizing multiple separate queries into a single query.
Syntax:
SELECT SALARY FROM
(SELECT SALARY, ROWNUN EP FROM
(SELECT SALARY FROM EMPLOYEES ORDER BY SALARY DESC) )
WHERE EP=7
Q72. What command is used to create a table by copying the structure of another table?
Syntax:
CREATE TABLE STU AS
SELECT * FROM STUDENTS
WHERE 1=2
Invalid Condition
We have to give the invalid condition in the where clause, where the whole data will copy to the new table (STU table).
Q73. Mention the use of the DROP option in the ALTER TABLE command.
The use of the DROP option in the ALTER TABLE command is to drop a particular COLUMN.
Syntax:
ALTER TABLE TABLE_NAME
DROP COLUMN COLUMN_NAME
Q74. What are the aggregate functions in SQL?
SQL aggregate functions allow us to return a single value, which is calculated from values in a column.
Following are the aggregate functions in SQL:
- AVG() : This function returns the average value
- COUNT(): This function returns the number of rows
- MAX() : It returns the largest value
- MIN() : This function returns the smallest value
- ROUND(): This function rounds a numeric field to the number of decimals specified
- SUM() : It returns the sum
Q75. Write the SQL query to update the student names by removing leading and trailing spaces.
This can be done by using ‘Update’ command with ‘LTRIM’ and ‘RTRIM’ function.
Syntax:
UPDATE StudentDetails
SET FullName = LTRIM(RTRIM(FullName));
Q76. Write the SQL query to fetch alternate records from a table
Records can be fetched for odd and even row numbers:
- Syntax to fetch even numbers:
Select employeeId from (Select rowno, employeeId from employee) where mod(rowno,2)=0
- Syntax to fetch odd numbers:
Select employeeId from (Select rowno, employeeId from employee) where mod(rowno,2)=1
Q77. How do you return a hundred books starting from the 15th?
The syntax will be:
SELECT book_title FROM books LIMIT 15, 100.
The first number in LIMIT is the offset, and the second is the number.
Q78. How will the query select all teams that lost either 1, 3, 5, or 7 games?
We will use-
SELECT team_name FROM teams WHERE team_lost IN (1, 3, 5, 7)
Q79. How will you delete a column?
We can delete a column by –
ALTER TABLE techpreparation_answers DROP answer_user_id.
Q80. What is the meaning of this query – Select User_name, User_isp From Users Left Join Isps Using (user_id)?
It means:
SELECT user_name, user_isp FROM users LEFT JOIN isps WHERE users.user_id=isps.user_id
crack your career with full stack developer course online !
Q81. How will you see all indexes defined for a table?
By using:
SHOW INDEX FROM techpreparation_questions;
Q82. How would you change a table to InnoDB?
By using:
ALTER TABLE techpreparation_questions ENGINE InnoDB;
Q83. Name the default port for the MySQL server.
The default port for the MySQL server is 3306.
Q84. What is the possible way to add five minutes to a date?
By using:
ADDDATE(techpreparation_publication_date, INTERVAL 5 MINUTE)
Q85. What is the possible way to convert between Unix timestamps and Mysql timestamps?
UNIX_TIMESTAMP converts from MySQL timestamp to Unix timestamp
FROM_UNIXTIME converts from Unix timestamp to MySQL timestamp
Q86. How do you implement Enums and sets internally in MySQL?
To implement an ENUM column, use the given syntax:
CREATE TABLE table_name ( … col ENUM (‘value1′,’value2′,’value3’), … );
Q87. How can we restart SQL Server in the single user or the minimal configuration modes?
The command line SQLSERVER.EXE used with ‘–m’ will restart SQL Server in the single-user mode.
The command line SQLSERVER.EXE used with ‘–f’ will restart it in the minimal configuration mode.
Q88. What is the use of the tee command in Mysql?
Tee is a UNIX command that sends a command’s standard output to the terminal as well as a file. The character tee followed by a filename enables MySQL logging to that particular file. A command note has the ability to pause it.
Power up your career with Entri Elevate – Full Stack Development Course!
Q89. Is it possible to save your connection settings to a conf file?
Yes, it is possible, and you can name it ~/.my.conf. You can also change the permissions on the file to 600 so that it’s not readable by others.
Q90. How to convert numeric values to character strings?
We can convert numeric values to character strings by using the CAST(value AS CHAR) function, as shown in the following examples:
SELECT CAST(4123.45700 AS CHAR) FROM DUAL;
4123.45700
Q91. Use mysqldump to create a copy of the database?
mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.sql
Q92. What are federated tables?
Federated tables in MySQL give users access to the tables located on other databases on different servers. It enables you to use a distant MySQL database without needing replication or cluster technology to access the data there. Data from the distant (federated) tables is retrieved when a local FEDERATED table is queried. The local tables don’t hold any data.
Q93. What are the different groups of data types in MySQL?
There are three groups of data types in MySQL, as listed below:
String Data Types – BINARY, VARBINARY, TINYBLOB, CHAR, NCHAR, VARCHAR, NVARCHAR, TINYTEXT, BLOB, TEXT, MEDIUMBLOB, LONGBLOB, LONGTEXT, ENUM, SET, MEDIUMTEXT.
Numeric Data Types – MEDIUMINT, INTEGER, BIGINT, FLOAT, BIT, TINYINT, BOOLEAN, SMALLINT, DOUBLE, REAL, DECIMAL.
Date and Time Data Types – TIMESTAMP, TIME, DATE, DATETIME, YEAR.
crack your career with full stack developer course online !
Q94. What is the procedure to concatenate two character strings?
To concatenate various character strings into one, you can use the CONCAT() function. Example:
SELECT CONCAT(’Naukri’,’ Learning’) FROM DUAL;
Shiksha Online
SELECT CONCAT(‘Learner’,’Thing’) FROM DUAL;
Learner Thing
Q95. What is the procedure to change the database engine in Mysql?
By using:
ALTER TABLE EnterTableName ENGINE = EnterEngineName;
Q96. What is the default storage engine in MySQL?
InnoDB is the default storage engine in MySQL.
Q97. What is COALESCE?
COALESCE returns the first non-NULL expression within its arguments from more than one column in the arguments.
The syntax for COALESCE is –
COALESCE (expression 1, expression 2, … expression n)
Q98. What syntax is used to create an index in MySQL?
By using-
CREATE INDEX [index name] ON [table name]([column name]);
Q99. How to store videos in an SQL Server table?
We use the FILESTREAM datatype to store videos in SQL server table.
Q100. Explain the use of the NVL() function.
The NVL()function converts the Null value to the other value.
Our Other Courses | ||
MEP Course | Quantity Surveying Course | Montessori Teachers Training Course |
Performance Marketing Course | Practical Accounting Course | Yoga Teachers Training Course |
Looking to sharpen your SQL skills and master the art of building dynamic, full-scale applications? Our full stack developer certification Course is designed to equip you with everything you need to become a versatile developer, from front-end design to back-end databases. Whether you’re solving complex SQL queries or deploying applications, this course offers hands-on experience with the latest tools and technologies to make you job-ready. Perfect for those aiming to excel in technical interviews and thrive in the evolving tech landscape of 2024!