Top 80 SQL Interview Questions & Answers

12-Oct-2022

If you're a programming and designer pro looking forward to landing a job in a reputed company and searching for a comprehensive guide for an interview, here is your best resource covering top SQL interview questions and answers. There is nothing like a well-prepared interview with guidance from a well-articulated set of SQL interview questions and answers. Your preparation for an SQL interview will be boosted massively with this article that details the most frequently asked and significant-top SQL interview questions and answers. 

This set of properly formulated SQL interview questions includes topics concerning both basic and advanced levels intended for candidates at both fresher and experienced levels.  

Basic Level Top SQL Interview Questions & Answers

1. What is SQL?

SQL which stands for Structured Querying Language is a programming language that is utilized for creating, updating, and modifying a database.  The relational database system makes use of SQL as the standard language. it is also the standard database language of all the relational databases including MS Access, MySQL, SQL Server, and Oracle.

2. Can you describe DBMS?

A database management system (DBMS) is a type of computer program used to create and manage databases. 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. 

DBMS can be categorized into two

  • RDBMS - Relational Database Management System, which stores data in relationships (tables). For instance- MySQL
  • Non-Relational Database management System or the non-tabular format of storing data. It is also referred to as NoSQL. For Instance- MongoDB

3. What is MySQL?

MySQL is also known as a Relational database management system (RDBMS). It 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. Frequently used for creating web applications, MySQL is renowned for its quickness, dependability, and versatility.

4. Briefly describe the subsets of SQL?

SQL has three subsets as categorized under:

  • DDL(Data Definition Language): This enables end users to CREATE, ALTER, and DELETE database items
  • DML (Data Manipulation Language): With this, the user can access and modify data. Data from the database can be inserted into it, updated, deleted, and retrieved.
  • DCL ( Data Control Language): The users can manage database accesses. It contains the ability to grant and revoke database manipulation and modification rights. 
  • You can manage database access using the Data Control Language (DCL). 

5. What is the primary Key in SQL?

Each row or record in a database table is uniquely identified by a primary key constraint. Primary Keys must have unique values. The primary key column does not accept null values or duplicate values. Per table should consist of only one primary key. It could include one or more fields.

6. What are the Foreign Keys?

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.

7. Can you explain RDBMS?

RDBMS means relational database management system. It is one of the most well-known database management systems built on the relational database concept. As the name suggests, it stores and allows access to data points related to one another. The databases here are built on the relational database concept, which is also intuitive, and straightforward in representing data in tables. Ina relational database system each table row is a record possessing a distinct ID identified as the key. The table's columns hold the data's properties, and each record normally includes a value for each property, making it easy to identify the relationships between data points.

8. What characteristics does MySQL have?

Below are a few of MySQL's key attributes:

  • It is trustworthy and simple to use.
  • It supports conventional SQL (Structured Query Language)
  • MySQL has a data security layer that shields sensitive data from unauthorized users, making it secure.
  • With its adaptable structure and broad support for embedded applications, MySQL
  • It is an extremely quick database language.
  • The database software is appropriate for both large and small applications.
  • Compared to other databases, MySQL provides extremely high-performance results.
  • Numerous well-known programming languages, including PHP, Java, and C++, support it.
  • It is free to use and download.

9. What are the drawbacks of MySQL?

The loopholes or disadvantages in MySQL can be listed here:

  • The difficulty of making MySQL scalable
  • Lack of efficiently supporting very large sizes of database
  • No support for SQL check constraint
  • Vulnerable to data corruption

10. How will you differentiate MySQL from SQL?

The distinction between MySQL and SQL can be made in the following aspects:

  • MySQL is a database that is based on the relational concept and employs SQL to query a database. However, SQL can be simply referred to as a query language. 
  • While MySQL supports multiple plug-in storage engines and storage engines, SQL is capable of supporting only one storage engine.
  • MySQL has the feature of storing existing data in an organized manner in the database SQL features actions like accessing, updating, and manipulating the data stored in a database. 
  • MySQL supports multiple platforms and has complex syntax, SQL supports only Windows and Linux and has a simpler syntax. 

11. Define Unique Key?

A unique Key can be defined as a set of one or more table fields or columns that are used to identify a record in a database table. This particular kind of unique key is a primary key in SQL.

12. Describe the various SQL index types?

SQL offers three different types of indexes:

Unique Index: If the column is unique indexed, it prevents a field from having duplicate values.

  • Clustered Index: This index specifies the physical storage order of data in a table. It searches using key values and changes the table's physical order. 
  • Non-Clustered Index: It preserves the logical order of the data while not sorting the table's physical order. There may be multiple non-clustered indexes for a given table.

13. Differentiate TRUNCATE from DELETE?

This question is among the topmost frequently raised SQL interview questions. Their differences can be listed below:

  • While DELETE command is employed for deleting a specified row in a table TRUNCATE is used for deleting all the rows from a table. 
  • In DELETE you have the option of rolling back data even after giving the delete command, but it is not possible in TRUNCATE. 
  • DELETE is a Data Management Language Command on the contrary TRUNCATE is a Data Definition Language Command. 
  • Amongst the two, TRUNCATE is a faster command, and DELETE is slower. 

14. What is the difference between VARCHAR and CHAR?

While VARCHAR is a variable-length character data type, CHAR is a fixed-length character data type. 

15. Define SQL subquery and explain its types?

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.
  • Non-related 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.

16. Define Collation Sensitivity?

Collation sensitivity, which is dependent on character width, accent marks, case sensitivities, and correct character sequence, among other factors, specifies the rules for sorting and comparing strings of character data.

17. Can you name the various types of Collation Sensitivity?

Collation Sensitivity is known to have four types, namely:

  • Accent sensitivity
  • Case sensitivity
  • Kana sensitivity
  • Width sensitivity

18. What are the various types of MySQL commands?

MySQL Commands are classified into the following types:

  • Data Definition Language (DDL)
  • Data Manipulation Language (DML)
  • Data Control Language (DCL)
  • Transaction Control Language (TCL)

19. What does the term" scheduled task" or "scheduled job" imply?

An automated task management system is made possible by scheduled jobs or tasks that run in predictable cycles. Administrative chores can be scheduled, and their priority can be chosen.

20. What are the various commands of DDL commands in MySQL?

DDL commands include –

  • CREATE – Used for creating the database or objects like table, function, views,  index, triggers, etc.
  • DROP – Used for deleting objects
  • ALTER – Used for changing database structures
  • TRUNCATE – Used for deleting all data or records from a table, except its database structure
  • COMMENT – Used for adding comments to the data dictionary
  • RENAME – Used for renaming a database object

21. What are the different DML commands in MySQL?

This is also another mostly raised SQL interview question. 

DML commands include –

  • SELECT – Used for selecting specific database data
  • INSERT – Used for inserting new records into a table
  • UPDATE – Aid in updating existing records
  • DELETE – Used for erasing existing records from a table
  • MERGE – Used for UPSERT operation which includes inserting or updating
  • CALL – Used in the event of a requirement of calling a PL/SQL or Java subprogram
  • EXPLAIN PLAN – Used for interpreting data access path
  • LOCK TABLE – Used for controlling concurrency

22. What are the various DCL commands in MySQL?

DCL commands are –

  • GRANT –  This command allows user access privileges to the database
  • DENY – Used for denying permissions to users
  • REVOKE – Used for withdrawing user access by using the GRANT command

23. Explain the varied TCL commands in MySQL.

  • The TCL commands in MySQL include –
  • COMMIT – Used for committing a transaction
  • ROLLBACK – Used for rolling back a transaction
  • SAVEPOINT – Used for rolling back the transaction within groups
  • SET TRANSACTION – Used for specifying transaction characteristics

24. Elucidate the types of Database relationships in MySQL?

Database Relationship is classified into three different types as explained below:

  • One-to-one: Here only one record is allowed for both tables
  • One-to-many: One or more records in the second table may be connected to the one record in the first table.
  • Many-to-many – In both tables, any number of records may be connected to any given entry.

25. How does normalization work?

An approach to database design called normalization organizes tables to lessen data reliance and redundancy.

26. Name the various types of Normalization?

Normalization is categorized into five types as given below –

  • 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)

27. Explain Denormalization?

Denormalization is a database optimization technique that involves adding redundant data to one or more tables to boost the performance of the database infrastructure.

28. In the MySQL table how many numbers of TRIGGERS are allowed?

In MySQL table the following Six TRIGGERS are allowed:

  • BEFORE INSERT
  • AFTER INSERT
  • BEFORE UPDATE
  • AFTER UPDATE
  • BEFORE DELETE 
  • AFTER DELETE

29. Are queries on MYSQL case-sensitive?

By default queries on MySQL are not case-sensitive.

30. What is the Syntax that is used for getting a version of MySQL?

A version of MySQL can e created by using SELECT version (); in your phpmyadmin

31. On which TCP/IP port does SQL server runs? Is it changeable?

SQL server operates on port 1433 and yes it is changeable from the Network Utility TCP/IP properties. 

32. What does SQL's Auto Increment entail?

When a new record is added to a table, auto-increment enables the generation of a unique number. Typically, we 

want the PRIMARY KEY field to be automatically produced each time a new record is put.

33. Can you explain a Database Relation?

The link between two relational database tables is known as a database relationship. The primary table consists of a foreign key referencing the primary key of another table. A Database Relation is classified into three types, namely:

  • One-to-one 
  • One-to-many 
  • Many-to-many

34. Which among a temporary table or a table variable is faster?

A temporary table is stored on a disc, however, a table variable is stored in memory which makes it typically faster. Both tables function similarly when the size of the table variable exceeds the available memory.

35. What are the symmetric key encryption algorithms that SQL server supports?

There are numerous symmetric key encryption algorithms that SQL Server supports. A few of them can are :

  •  DES
  • Triple DES
  •  RC2
  •  RC4
  • 128-bit 
  • RC4
  • DESX
  • 128-bit AES 
  • 192-bit AES
  •  256-bit AES

36. Which command is applied to get back the privileges that GRANT Command?

In order to get back the privileges that GRANT Command offers the command REVOKE is used. 

37. What Does a SQL Clause Mean?

An SQL clause is a component of a query that enables consumers to filter or personalize how their data is requested of them. By adding a condition to the query, users can restrict the result set. A 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. For example:

WHERE and HAVING clauses

38. Describe the "WHERE" and "HAVING" clauses?

One of the most significant SQL interview questions is this question on describing clauses. 

The WHERE clause is used to combine multiple tables or to filter the records in a table. If the criteria in the WHERE clause are met, it returns the specific value from the table. It is used to filter data from the table or relation with SELECT, INSERT, UPDATE, and DELETE queries.

The HAVING clause is applied to 

Based on the specified condition in the HAVING Clause, the records from the groups are filtered using the HAVING clause. It is only appropriate for usage with the SELECT query. Only values from the groups in the final result that meet specific requirements are returned.

For Example:

SELECT name, SUM(working_hour) AS “Total working hours”

FROM employees GROUP BY name

HAVING SUM(working_hour) > 6;

39. What does the SELECT statement mean?

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;

40. What distinguishes the "WHERE" Clause from the "HAVING" Clause?

The key distinctions between the "WHERE" Clause and the "HAVING" Clause are listed below:

Based on the defined criterion, the WHERE Clause filters each individual row. The HAVING clause filters groups depending on the given criterion.

You can use the WHERE clause without the GROUP BY clause. Always use HAVING after the GROUP BY Clause.

Row operations use the WHERE Clause. While Column operations use the HAVING operator.

The WHERE clause is incompatible with aggregate functions. With aggregate functions, this clause is functional.

GROUP BY comes after WHERE. GROUP BY comes before HAVING. Using the WHERE clause as a pre-filter 

Using the WHERE clause as a pre-filter. A post-filter is provided via the HAVING clause. 

SELECT, INSERT, UPDATE, and DELETE statements can all be used with the WHERE Clause. But HAVING Clause is only applicable and used with Statement. 

41. How do find the following:

Entries with the same field twice?

Duplicating data with several fields?

Finding duplicate entries with similar field: 

  • SELECT COUNT(field)
  • FROM table_name
  • GROUP BY field
  • HAVING COUNT(field) > 1
  • Finding duplicate records with several field:
  • SELECT field1,field2,field3, COUNT(*)
  • FROM table_name
  • GROUP BY field1,field2,field3
  • HAVING COUNT(*) > 1

42. Define Constraint and name the types of levels?

Constraints may be defined as the column representation to provide data consistency and entity. Constraints are of two levels:

Column Level- Limits only the data at the column level.

Table level - Limits all data in the table.

The most popular limitations that can be used on a table are as follows:

  • NOT NULL
  • UNIQUE
  • CHECK
  • DEFAULT
  • PRIMARY KEY
  • FOREIGN KEY

43. What types of authentication does SQL Server support?

SQL Server offers two types of authentication:

  • Default Windows Mode-This Windows-integrated SQL Server security model
  • Mixed Mode - Supports Windows and SQL Server authentication
  • By choosing the tools option from the SQL Server configuration options, we may switch between modes by hovering over the security page.

44. Explain PL/SQL?

The Procedural Language for SQL, also known as 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.

45. Describe SQL Profiler?

SQL Server Profiler is a graphical user interface for collecting and storing information about each file event. When an issue is identified, it also enables a system administrator to examine and playback trace results. Uses for SQL Server Profiler include:

  • Examine the problematic queries to determine what is causing the issue.
  • Identify slow-moving queries
  • The Transact-SQL statements that cause an issue should be identified.
  • Follow the SQL Server's performance.
  • Connect performance counters to identify issues

46. Briefly explain SQL Server Agent?

The SQL Server Database Administrator's daily activities or jobs are carried out by the SQL Server Agent, a Microsoft Windows service (DBA). This service makes it possible to carry out actions at a specified time and date.

47. Define Data Integrity?

Data accuracy, completeness, and consistency are characteristics of a database's 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 Integrity
  • Entity Integrity
  • Referential Integrity

48. What distinguishes a rename from an alias?

Ans. Renaming an object actually involves giving it a new name. Giving an existing object a new name is known as aliasing it. Renaming a database item entails giving it a new, permanent name, as opposed to giving it an alias, which is only used temporarily.

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};

49. Which steps make up Data Modeling's primary steps?

The primary steps in data modeling are as follows:

Determine and analyze the business needs 

Make an excellent conceptual and logical data model.

Using a data modeling tool, choose the target database to generate scripts for the physical schema.

50. Define Referential Integrity?

Referential integrity is a relational database concept that states that primary and foreign keys should be kept consistent and accurate.

51. Can you define Business intelligence in brief?

Business Intelligence covers a range of technology and techniques including gathering, integrating, analyzing, and presenting business information. It includes best practices, data tools and infrastructure, data mining, data visualization, and business analytics.

52. What are the varied privileges that SQL offers?

The various privileges that are 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 administrative duties, change any cache group, and change any index.

Object Privilege: 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, UPDATE, DELETE, SELECT, FLUSH, LOAD, INDEX, REFERENCES, and others use additional object rights.

53. What distinguishes a clustered index from a non-clustered index?

Ans. A clustered index is applied while ordering rows in a table. It has leaf nodes made up of data pages. A table can have only a single clustered index. 

While in a Non-clustered Index data storing and indices are distributed over several locations. Leaf nodes that house index rows are also present. There may be many non-clustered indexes in a table.

54. Explain ERD?

A visual representation of database systems that demonstrates the relationship between tables is called an entity relationship diagram, or ERD. Three components make up the ER Diagrams:

Entities: A person, place, thing, or event for which data is gathered is referred to as an entity.

Attributes: The information we wish to gather for an entity is referred to as its attributes. It is a quality, trait, or feature of a thing, a connection, or another attribute.

Relationships: It describes how things relate to one another.

55. What does SQL's ACID property mean?

ACID simply means Atomicity, Consistency, Isolation, and Durability. Throughout a transaction, it guarantees Data Integrity.

  • Atomicity: This refers to the fact that either all insert, update, and delete actions within a transaction occur, or none do. Therefore, if even one component of a transaction fails, the complete transaction will also fail, leaving the database state unaffected.
  • Consistency: Consistency guarantees that the data must adhere to all requirements for validation. The consistency feature ensures that no transaction ever leaves your database incomplete, regardless of what happens in the middle of it.
  • Isolation: Every transaction is individual due to isolation. Until a transaction is finished, it cannot access the outcomes of previous transactions.
  • Durability: It suggests that keeping track of committed transactions' updates 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.

56. What is the function of string in SQL?

String functions are employed for string manipulation. 

Below are the SQL string functions that are used extensively:

  • UPPER(): changes data character to upper case
  • LOWER(): changes data character to lowercase
  • SUBSTRING() : Generate characters from a text field
  • RTRIM(): Erases all whitespace at the string end
  • LEN(): Restore the value length in a text field
  • REPLACE(): Updates the string content 
  • LTRIM(): Erases all whitespace from the string's starting point
  • CONCAT(): Integrate multiple character strings

57. Give the SQL server's encryption techniques a name?

The SQL servers' encryption mechanisms are:

Transact-SQL functions - When inserting or updating a single item, Transact-SQL functions allow for its encryption.

Asymmetric keys - They consist of a corresponding private key and a corresponding public key. 

Data encrypted by one key has the possibility of getting decrypted by the other key.

Symmetric keys are employed in both the encryption and decryption processes.

Certificate: It ties the value of a public key to the identity of the person, machine, or service that controls the matching private key, and is also referred to as a public key certificate.

Transparent data encryption encrypts the entirety of a database using a symmetric key as a specific case of encryption.

Can a view be added, altered, or deleted? If so, under what circumstances?

Ans. If a view includes any of the following, adding the data through that view is not possible:

  • Group by clause 
  • Group functions 
  • DISTINCT keyword 
  • Columns defined by expressions 
  • Pseudo column ROWNUM keyword 
  • NOT NULL column in table base unselected by the view

58. Define an inline view?

A SELECT statement in the FROM-clause of another SELECT query is known as an inline view. By eliminating join procedures and condensing numerous independent inquiries into a single query, in-line views are used to simplify complex queries.

59. Name the aggregate SQL Functions?

By using SQL aggregate functions, we may calculate a single value from the values in a column.

The SQL aggregate functions are as follows:

  • AVG(): This procedure provides the average value.
  • COUNT(): The number of rows returned by this function.
  • MAX(): It gives back the highest value.
  • MIN() : This function gives back the lowest value.
  • ROUND(): This function adds the provided number of decimals to a numeric field.
  • SUM(): It provides the whole.

60. To change the student names by deleting the leading and trailing spaces, use a SQL query?

The "Update" command with the "LTRIM" and "RTRIM" functions can be used to do this. 

Syntax:

UPDATE StudentDetails 

SET FullName = LTRIM(RTRIM(FullName));

SQL interview questions & answers, top SQL interview questions & answers

61. What function does MySQL's Tee command serve?

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. 

62. Can you save your connection preferences to a conf file?

It is feasible and you can give it the name /.my.conf. To prevent others from reading the file, you can alternatively change its permissions to 600.

63. Name MySQL's data types groups?

MySQL data types can be categorized into three groups as below:

String Data Types- Consisting of the following 

  • BINARY
  • VARBINARY
  • TINYBLOB
  • CHAR
  • NCHAR 
  • VARCHAR
  • NVARCHAR
  • TINYTEXT
  • BLOB
  • TEXT
  • MEDIUMBLOB
  •  LONGBLOB
  •  LONGTEXT
  •  ENUM 
  • SET
  • MEDIUMTEXT

Numeric Data Types – That consist of the following 

  • MEDIUMINT
  • INTEGER, 
  • BIGINT
  • FLOAT 
  • BIT
  • TINYINT
  • BOOLEAN 
  • SMALLINT
  • DOUBLE
  • REAL
  • DECIMAL

Date and Time Data Types – Consisting of -

  • TIMESTAMP
  • TIME
  • DATE
  • DATETIME
  • YEAR

64. Describe COALESCE?

The first non-NULL phrase in all of the parameters, including those from multiple columns, is what COALESCE returns.

The syntax for COALESCE is –

COALESCE (expression 1, expression 2, … expression n)

65. Name the SQL default storage engine?

The default storage engine for SQL is the InnoDB

66. How are videos stored in the SQL server table?

For storing videos in the SQL server table the datatype FILESTREAM is employed. 

67. What is the purpose of the NVL() function?

The NVL() function has the task of converting the Null value to another value. 

68. Give the standard procedure of the concatenate process of two character strings?

For performing the concatenate procedure of multiple strings into one, the function CONCAT() is employed. 

69. Explain how to change the MySQL database engine?

MySQL database engine can be changed by using the below 

ALTER TABLE EnterTableName ENGINE = EnterEngineName;

70. How will you differentiate MyISAM from InnoDB?

We can lay out the differences between the two in the  following points:

While MyISAM does not support transactions any longer, InnoDB does support transactions. 

MyISAM also features supporting Table-level locking while InnoDB features Row-level locking. 

While InnoDB supports ACID property MyISAM no longer does.  

FULLTEXT index is supported by MyISAM but not by InnoDB.

71. Name the drivers available in MySQL?

 MySQL features the following drivers:

  • PHP Driver
  • C WRAPPER
  • ODBC Driver
  • JDBC Driver
  • PYTHON Driver
  • RUBY Driver
  • PERL Driver
  • CAP11PHP Driver
  • Ado.net5.mxj

72. What are the various MySQL storage engines and table types?

MySQL supports both transaction-safe tables (such as InnoDB and BDB) and tables that are not transaction-safe (HEAP, ISAM, MERGE, and MyISAM).

MyISAM: This is an indexed sequential access method-based default table type (ISAM). The previous ISAM storage engine is expanded. 

These tables have had speed and compression optimized.

HEAP enables quick data access. However, if there is a crash, the data will be lost. BLOB, TEXT, and AUTOINCREMENT fields are not allowed in HEAP tables.

BDB: It supports COMMIT and ROLLBACK transactions. 

The others are faster than it.

MERGE is a virtualized table that integrates numerous MyISAM tables that are structurally similar to one another. It is also referred to as the MRG MyISAM engine.

InnoDB: These tables completely handle transactions that are ACID-compliant.

73. Define Join. What kinds of joins does MySQL support?

A join query retrieves rows or columns that are connected. In MySQL, there are four distinct join types:

  • Inner Join: If there exists at least a single match between two tables, the inner join returns the rows.
  • Left Join: Despite the absence of a match in the right table, the left join still returns all the rows from the left table.
  • Right Join: Even if there are no matches in the left table, the right join nevertheless retrieves all the rows from the right table.
  • Full Join: When there is at minimum one match between the tables, a full join would return rows.

74. What does a SQL operator for pattern matching do?

If you don't know what that word should be, you can still look for patterns in data using SQL's Pattern Matching operator. This operator matches a string pattern using wildcards rather than the specific word. SQL Wildcards are used in conjunction with the LIKE operator to retrieve the necessary data.

LIKE operator is used for pattern matching in the below format:

  • % – Matching zero or more characters.
  • _ (Underscore) – Matching exactly one character.

75. Define a Stored Procedure?

An SQL function called a stored procedure uses multiple SQL statements to access a database system. It can be used multiple times and kept for subsequent use. You only need to invoke the stored procedure if you need to complete a specific operation frequently instead of writing the statements by hand. This saves time and prevents the need to write new code.

76. List out the major advantages of a Stored Procedure?

The following are some of the benefits of a Stored Procedure:

  • Once stored procedures are built and stored in executable form, execution becomes quick and effective.
  • Modular programming can be done using a stored procedure. It can be frequently called whenever necessary once it has been constructed and kept.
  • It is simpler to maintain a procedure on a server than it is to keep copies on many client machines.
  • Improved security

77. What are the disadvantages of a Stored Procedure?

The drawbacks of a Stored Procedure are:

  • It only works with databases and takes up extra RAM on the database server.
  • The generation of any data errors in stored procedures does not occur until runtime.
  • Not supported is version control.

78. What are the STUFF and REPLACE functions in SQL?

The STUFF function replaces a string's substring of a specific length with a new string after deleting the substring. The string is inserted at the provided location, and the specified number of characters is removed from the starting string.

The REPLACE function substitutes a different string for every instance of a particular string value.

79. Define a Database cursor?

The technology that enables traversal over a database's records is called a database cursor. Cursors also enable processing following traversals, such as database record retrieval, insertion, and deletion. A cursor behaves similarly to an iterator in a computer language.

80. How is a Database Cursor used in SQL Procedures?

  • Make variables known.
  • Declare a cursor with a result set defined. There must always be a SELECT Statement in conjunction with the cursor declaration.
  • To begin the result set, move the cursor.
  • To obtain and advance to the following row in the result set, use the FETCH command.
  • Cursor closed.
  • Get rid of the cursor.

Those are the top SQL interview questions and answers that will boost your interview preparation and give you an idea of what questions you may expect.

Read More

Top 80 Python Interview Questions & Answers

Top 50 React Interview Questions and Answers in 2022

Top 50 Blockchain Interview Questions and Answers

Investment Banking Interview Questions and Answers

Top 50 Project Management (PMP) Interview Questions & Answers

Top 50 Agile Interview Questions And Answers

Top 30 Data Engineer Interview Questions & Answers

Top 50 Network Security Interview Questions and Answers

Top 80 Data Science Interview Questions & Answers

Cyber Security Architect Interview Questions and Answers

Top 120 Cyber Security Interview Questions & Answers in 2022

Top Project Manager Interview Questions and Answers

Top 50 Angular Interview Questions & Answers

Top 50 Tableau Interview Questions and Answers

Top 50 Artificial Intelligence Interview Questions and Answers

Top 50 R Interview Questions & Answers

Top 50 AWS Architect Interview Questions

Top 30 Machine Learning Interview Questions & Answers

Top 50 Hadoop Interview Questions & Answers

Top 80 Azure Interview Questions & Answers

Top 50 Power Bi Interview Questions & Answers

Top 80 Digital Marketing Questions & Answers

Top 50 Big Data Interview Questions & Answers

Post a Comment

Submit
Top