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

No comments:

Post a Comment