Basic SQL interview questions and answers

  1. What is SQL?   SQL stands for Structured Query Language. It is for managing databases. Basic SQL and dialects of the same are used for MySQL, SQL Server, Microsoft Access, Oracle, ,Sybase, DB2 and other database systems. The syntax changes by verbal languages (French, Danish, Spanish, etc.) It has a sentence-like structure with an understood subject: [do an action] [action] [objects of the action, such as fields] [conditions of the action]
  2. 2.      What is DDL?    DDL is the data definition language which functions on a table lever. This allows database tables to be created or deleted, defines indexes and specific links between tables, and imposes constraints between tables. Examples of statements in DDL are create database, alter database, create table, alter tables, drop table, create index and drop index.
  3. 3.      What is DML?  This stands for data manipulation language and applies to actions which can be done to database objects. Examples of these commands are select, update, delete and insert into.
  4. 4.      What is a result set?  A result set is the virtual array which is created by a query. This may then be acted on to create a new result set.
  5. 5.      What is the Select Distinct statement?  This is a select statement which does not select duplicates within the parameter field, whereas a plain Select statement would show all results.
  6. 6.      What are wildcards and how are they used?  Wildcards are like those in a card game; they can stand for anything or can have constraints such as any card of the hearts suit. A wildcard in SQL can be a substitute for zero or more characters ( % ), exactly one character ( — ), a single character in a charlist ( [charlist] ) or any single character which is not in a charlist ( [^charlist] or [!charlist] ).
  7. 7.      What is a join?  A join is a method for extracting data from two or more tables based on particular columns (fields) in these tables. The primary key of one table is “linked” or joined to the same primary key content in another table. The result set would only contain records with agreement between the two tables unless the Join statement is modified.
  8. 8.      Compare primary and foreign keys.  The primary key in a table is the index for the data in that table and must not be duplicated, giving each record a unique identification. The foreign key in a table is the primary key in another table; it can have duplicates (as in a one-to-many relationship).
  9. 9.      What are SQL functions?  These are built-in calculations to be performed on data. Function syntax is the function(), where the parameters of the function are within the parentheses. They may return information for numeral calculations, character values, field data, and other database properties and values.
  10. 10.  What are the different types of SQL functions?  There are aggregate functions such as AVG(), COUNT(), and MAX(); and scalar functions such as UCASE(), LEN() and FORMAT(). There are at least sixteen built-in functions. These are used in queries. Other functions can be coded in

Leave a Reply

Your email address will not be published.