Showing posts with label MySQL Questions and Answers. Show all posts
Showing posts with label MySQL Questions and Answers. Show all posts

Tuesday, 10 February 2015

Experienced MySQL Interview Questions and Answers (Page 7)

Below are some important MySQL interview questions which are asked in most MNC company interviews for beginners or professionals.

31. How To Get a List of Indexes of an Existing Table?
If you want to see the index you have just created for an existing table, you can use the “SHOW INDEX FROM tableName” command to get a list of all indexes in a given table. The tutorial script below shows you a nice example:

32. How To Drop an Existing Index in MySQL?
If you don’t need an existing index any more, you should delete it with the “DROP INDEX indexName ON tableName” statement. Here is an example SQL script:
mysqi> DROP INDEX tip_subject ON tip;
Query OK, 0 rows affected (0.13 sec)
Records: 0 Duplicates: 0 Warnings: 0

33. How To Create a New View in MySQL?
You can create a new view based on one or more existing tables by using the “CREATE VIEW viewName AS selectStatcment” statement as shown in the following script:
mysqi> CREATE TABLE comment (faqiD INTEGER,
message VARCHAR(256));
Query OK, 0 rows affected (0.45 see)
mysqi> INSERT INTO comment VALUES (1, ‘1 like it’);
Query OK, 1 row affected (0.00 see)

mysqi> CREATE VIEW faqCornrnent AS SELECT f.id. f.title,
f.description, c.rnessage FROM faq 1., comment c
WHERE f.id = c.faqlD;
Query OK, 0 rows affected (0.06 see)
mysqi> SELECT * FROM faqCorr.ment;

34. How To Drop an Existing View in MySQL?
If you have an existing view, and you dont want it anymore, you can delete it by using the “DROP VIEW viewName” statement as shown in the following script:
mysql> DROP VIEW faqComment;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM faqComment;
ERROR 1146 (42502): Table ggI.faqcomment doesn’t exist
More Questions & Answers :-
Page1  Page2  Page3  Page4  Page5  Page6  
Page7

MySQL Admin Interview Questions and Answers (Page 6)

Below are some important MySQL interview questions which are asked in most MNC company interviews for beginners or professionals.

26. How To Add a New Column to an Existing Table in MySQL?
ALTER TABLE tip ADD COLUMN author VARCHAR(40);
Query OK, 1 row affected (0.18 sec)
Records: 1 Duplicates: 0 Warnings: 0

27. How To Delete an Existing Column in a Table?
ALTER TABLE tip DROP COLUMN create_date;
Query OK, 1 row affected (0.48 sec)
Records: 1 Duplicates: 0 Warnings: 0

28. Flow To Rename an Existing Column in a Table?
ALTER TABLE tip CHANGE COLUMN subject
title VARCHAR(60);

29. How To Rename an Existing Table in MySQL?
ALTER TABLE tip RENAME TO faq;

30. How To Create a Table Index in MvSQL?
If you have a table with a lots of rows, and you know that one of the columns will be used often as a search criteria, you can add an index for that column to improve the search performance. To add an index, you can use the “CREATE INDEX” statement as shown in the following script:
mysql> CREATE TABLE tip (id INTEGER PRIMARY KEY,
subject VARCHAR(80) NOT NULL,
description VARCHAR(256) NOT NULL,
create_date DATE NULL);
Query OK, 0 rows affected (0.08 sec)
mysql> CREATE INDEX tip_subject ON tip(subject);
Query OK, 0 rows affected (0.19 sec)
Records: 0 Duplicates: 0 Warnings: 0
More Questions & Answers :-
Page1  Page2  Page3  Page4  Page5  Page6  Page7

MySQL Database Interview Questions for Beginners and experienced (Page 5)

Below are some important MySQL interview questions which are asked in most MNC company interviews for beginners or professionals.

21. How To Use IN Conditions?
An IN condition is single value again a list of values. It returns TRUE, if the specified value is in the list.
Otherwise, it returns FALSE.
Some examples are given in the tutorial exercise below:
 SELECT 3 IN (1,2,3,4,5) FROM DUAL;
1
SELECT 3 NOT IN (1,2,3,4,5) FROM DUAL;
0
SELECT Y’ IN (‘F’,’Y’,I) FROM DUAL;
1

22. How To Use LIKE Conditions?
A LIKE condition is also called pattern patch. There are 3 main rules on using LIKE condition:
* is used in the pattern to match any one character.
* % is used in the pattern to match any zero or more characters.
* ESCAPE clause is used to provide the escape character in the pattern.
The following tutorial exercise provides you some good pattern matching examples:
SELECT GlobalGuideLine.com LIKE ‘%center% FROM DUAL;
1
SELECT GlobalGuideLine.com’ LIKE ‘%CENTER% FROM DUAL;
1
-- Case insensitive by default
SELECT GlobalGuideLine.com LIKE ‘%CENTER_com’ FROM DUAL;
1

23. How To Increment Dates by 1111 MvSQL?
If you have a date, and you want to increment it by 1 day, you can use the DATE_ADD(date, INTERVAL 1 DAY) function. You can also use the date interval add operation as “date + INTERVAL 1 DAY. The tutorial exercise below gives you some good examples:
SELECT DATE_ADD(DATE(1997-01-3 1), INTERVAL 1 DAY)
FROM DUAL;
1997-02-01
SELECT DATE(1997-01-31) + INTERVAL 1 DAY FROM DUAL;
1997-02-01

24. How To Calculate the Difference between Two Dates?
If you have two dates, and you want to know how many days between them, you can use the DATEDIFF(datel, date2) function as shown below:
SELECT DATEDI FF( DATE(’1997-02-28’), DATE(’1997-03-01’))
FROM DUAL;
-1 and different between two time is TIMEDIFF()

25. Flow To Present a Past Time in Hours, Minutes and Seconds?
If you want show an article was posted “n hours n minutes and n seconds ago’, you can use the TIMEDIFF(NOWO, pastTime) function as shown in the following tutorial exercise:
SELECT TIMEDIFF(NOWO, ‘2006-07-01 04:09:49’) FROM DUAL;
06:42:58
SELECT TIM E_FORMAT(TI M EDI FF( NOWO, ‘2006-06-30 04:09:49’),
‘%H hours, %i minutes and %s seconds ago.’) FROM DUAL;
30 hours, 45 minutes and 22 seconds ago.
More Questions & Answers :-

Basic MySQL Interview Questions for Database (Page 4)

Below are some important MySQL interview questions which are asked in most MNC company interviews for beginners or professionals.

16. How To Concatenate Two Character Strings?
If you want concatenate multiple character strings into one, you need to use the CONCAT() function. Here are some good examples:
SELECT CONCAT(’Welcome’,’ to’) FROM DUAL;
Welcome to
SELECT CONCAT(ggl’,’center’,’.com’) FROM DUAL;
GlobalGuideLi ne.com

17. How To Enter Characters as HEX Numbers?
If you want to enter characters as HEX numbers, you can quote HEX numbers with single quotes and a prefix of (X), or just prefix HEX numbers with (Ox). A HEX number string will be automatically converted into a character string, if the expression context is a string. Here are some good examples:
SELECT X313233’ FROM DUAL;
123
SELECT 0x414243 FROM DUAL;
ABC
SELECT Ox46594963656E7465722E636F6D FROM DUAL;
GlobalGuideLi ne.com

18. How To Enter Boolean Values in SQL Statements?
If you want to enter Boolean values in SQL statements, you use (TRUE), (FALSE), (true), or (false). Here are some good examples:
SELECT TRUE, true, FALSE, false FROM DUAL;

19. How To Convert Numeric Values to Character Strings?
You 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
--
20. How to get rid of the last 2 0’s?
SELECT CAST(4.12345700E+3 AS CHAR) FROM DUAL;
4123.457
SELECT CAST(1/3 AS CHAR);
0.3333
More Questions & Answers :-

mysql dba interview questions and answers (Page 3)

Below are some important MySQL interview questions which are asked in most MNC company interviews for beginners or professionals.

11. What Is Commit?
Commit is a way to terminate a transaction with all database changes to be saved permanently to the database server.

12. What Is Rollback?
Rollback is a way to terminate a transaction with all database changes not saving to the database server.

13. How Many Groups of Data Types?
MySQL support 3 groups of data types as listed below:
 String Data Types - CHAR, NCHAR, VARCHAR, NVARCHAR, BINARY, VARBINARY, TINYBLOB, TINYTEXT,
BLOB, TEXT, MEDIUMBLOB, MEDIUMTEXT, LONGBLOB, LONGTEXT, ENUM, SET
Numeric Data Types - BIT, TINYINT, BOOLEAN, SMALLINT, MEDIUMINT, INTEGER, BIGINT, FLOAT,
DOUBLE, REAL, DECIMAL.
Date and Time Data Types - DATE, DATETIME, TIMESTAMP, TIME, YEAR.

14. What Are the Differences between CHAR and NCHAR?
Both CHAR and NCHAR are fixed length string data types. But they have the following differences:
CHARs full name is CHARACTER.
NCHARs full name is NATIONAL CHARACTER.
By default, CHAR uses ASCII character set. So 1 character is always stored as 1 byte.
By default, NCHAR uses Unicode character set. NCHAR data are stored in UTF8 format. So 1 character
could be stored as 1 byte or upto 4 bytes.
Both CHAR and NCHAR columns are defined with fixed lengths in units of characters.

15. How To Escape Special Characters in SQL statements?
There are a number of special characters that needs to be escaped (protected), if you want to include them in a character string. Here are some basic character escaping rules:
The escape character () needs to be escaped as (\).
The single quote (‘) needs to be escaped as (‘) or (“) in single-quote quoted strings.
The double quote () needs to be escaped as (“) or (““) in double-quote quoted strings.
The wild card character for a single character () needs to be escaped as (_).
The wild card character for multiple characters (%) needs to be escaped as (%).
The tab character needs to be escaped as (t).
The new line character needs to be escaped as (n).
The carriage return character needs to be escaped as (r).
More Questions & Answers :-

PHP-MySQL Interview Question and Answers pdf (Page 2)

Below are some important MySQL interview questions which are asked in most MNC company interviews for beginners or professionals.

6. What Is Union?
Join is data retrieval operation that combines multiple query outputs of the same structure into a single output. By default the MySQL UNION removes all duplicate rows from the result set even if you don’t explicit using DISTINCT after the keyword UNION.
SELECT customerNumber id, contactLastname name
FROM customers
UNION
SELECT employeeNurrber id, firstname name
FROM employees
id name
103 Schmitt
112 King
114 Ferguson
119 Labrune
121 Bergulfsen

7. What Is ISAM?
ISAM (Indexed Sequential Access Method) was developed by IBM to store and retrieve data on secondary storage systems like tapes.

8. What Is InnoDB?
lnnoDB is a transaction safe storage engine developed by Innobase Oy (an Oracle company now).
What Is BDB (BerkeleyDB)?
BDB (BerkeleyDB) is transaction safe storage engine originally developed at U.C. Berkeley. It is now developed by Sleepycat Software, Inc. (an Oracle company now).

9. What Is CSV?
CSV (Comma Separated Values) is a file format used to store database table contents, where one table row is stored as one line in the file, and each data field is separated with comma.

10. What Is Transaction?
A transaction is a logical unit of work requested by a user to be applied to the database objects. MySQL server introduces the transaction concept to allow users to group one or more SQL statements into a single transaction, so that the effects of all the SQL statements in a transaction can be either all committed (applied to the database) or all rolled back (undone from the database).
More Questions & Answers :-

34 TOP MySQL Interview Questions and Answers for freshers and experienced pdf

Below are some important MySQL interview questions which are asked in most MNC company interviews for beginners or professionals.

1. What is DDL, DML and DCL?
If you look at the large variety of SQL commands, they can be divided into three large subgroups. Data Definition Language deals with database schemas and descriptions of how the data should reside in the database, therefore language statements like CREATE TABLE or ALTER TABLE belong to DDL. DML deals with data manipulation, and therefore includes most common SQL statements such SELECT, INSERT, etc. Data Control Language includes commands such as GRANT, and mostly concerns with rights, permissions and other controls of the database system.

2. What is primary key?
A primary key is a single column or multiple columns defined to have unique values that can be used as row identifications.

3. What Is Foreign Key?
A foreign key is a single column or multiple columns defined to have values that can be mapped to a primary key in another table.

4. What Is Index?
An index is a single column or multiple columns defined to have values pre-sorted to speed up data retrieval speed.

5. What Is Join?
Join is data retrieval operation that combines rows from multiple tables under certain matching conditions to form a single row.
More Questions & Answers :-