October 13, 2018

Sreekanth B

Red Hat Most Frequently Asked Latest MySQL Interview Questions Answers

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(wj’,’center’,’.com’) FROM DUAL;
wisdomjobs.com

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

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;
Red Hat Most Frequently Asked Latest MySQL Interview Questions Answers
Red Hat Most Frequently Asked Latest MySQL Interview Questions Answers

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

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

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 :

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

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.

How 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 are:

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.

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

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

How To Rename An Existing Column In A Table?

ALTER TABLE tip CHANGE COLUMN subject title VARCHAR(60);

How To Rename An Existing Table In Mysql?

ALTER TABLE tip RENAME TO faq;

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:

<pre>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)</pre>
mysql> CREATE INDEX tip_subject ON tip(subject);
Query OK,
0 rows affected (0.19 sec)
Records: 0 Duplicates: 0 Warnings: 0.

Subscribe to get more Posts :