YouTube Icon

Interview Questions.

Top 100+ Mysql Interview Questions And Answers - May 31, 2020

fluid

Top 100+ Mysql Interview Questions And Answers

Question 1. What's Mysql ?

Answer :

MySQL (said "my ess cue el") is an open source relational database management gadget (RDBMS) that uses Structured Query Language (SQL), the maximum popular language for adding, accessing, and processing facts in a database. Because it's far open supply, every body can download MySQL and tailor it to their desires according with the majority license. MySQL is noted specifically for its velocity, reliability, and versatility.

Question 2. What Is Ddl, Dml And Dcl ?

Answer :

If you take a look at the massive sort of SQL commands, they can be divided into three massive subgroups. Data Definition Language deals with database schemas and descriptions of how the records should live in the database, therefore language statements like CREATE TABLE or ALTER TABLE belong to DDL. DML deals with data manipulation, and therefore consists of most not unusual SQL statements such SELECT, INSERT, and many others. Data Control Language includes instructions which include GRANT, and in general issues with rights, permissions and different controls of the database device.

PHP Interview Questions
Question three. How Do You Get The Number Of Rows Affected By Query?

Answer :

SELECT COUNT (user_id) FROM customers might only return the number of user_id’s.

Question 4. If The Value In The Column Is Repeatable, How Do You Find Out The Unique Values?

Answer :

Use DISTINCT in the query, inclusive of SELECT DISTINCT user_firstname FROM customers; You can also ask for a number of awesome values by using saying SELECT COUNT (DISTINCT user_firstname) FROM users;

PHP Tutorial
Question 5. How Do You Return The A Hundred Books Starting From 25th?

Answer :

SELECT book_title FROM books LIMIT 25, one hundred. The first wide variety in LIMIT is the offset, the second one is the range.

PHP+MySQL Interview Questions
Question 6. You Wrote A Search Engine That Should Retrieve 10 Results At A Time, But At The Same Time You'd Like To Know How Many Rows There're Total. How Do You Display That To The User?

Answer :

SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS(); The second query (no longer that COUNT() is never used) will tell you what number of outcomes there’re overall, so that you can show a phrase "Found thirteen,450,600 effects, showing 1-10". Note that FOUND_ROWS does now not be aware of the LIMITs you precise and always returns the total quantity of rows affected by question.

Question 7. How Would You Write A Query To Select All Teams That Won Either 2, 4, 6 Or eight Games?

Answer :

SELECT team_name FROM teams WHERE team_won IN (2, four, 6, 8)

MySQL Tutorial Drupal Interview Questions
Question 8. How Would You Select All The Users, Whose Phone Number Is Null?

Answer :

SELECT user_name FROM users WHERE ISNULL(user_phonenumber);

Question nine. What Does This Query Mean: Select User_name, User_isp From Users Left Join Isps Using (user_id) ?

Answer :

It’s equal to announcing SELECT user_name, user_isp FROM customers LEFT JOIN isps WHERE customers.User_id=isps.User_id

MYSQL DBA Interview Questions
Question 10. How Do You Find Out Which Auto Increment Was Assigned On The Last Insert?

Answer :

SELECT LAST_INSERT_ID() will go back the ultimate fee assigned by the auto_increment function. Note that you don’t should specify the desk call.

Drupal Tutorial
Question eleven. What Does -i-am-a-dummy Flag To Do When Starting Mysql?

Answer :

Makes the MySQL engine refuse UPDATE and DELETE commands where the WHERE clause isn't always present.

PHP5 Interview Questions
Question 12. On Executing The Delete Statement I Keep Getting The Error About Foreign Key Constraint Failing. What Do I Do?

Answer :

What it way is that so of the facts that you’re looking to delete remains alive in any other desk. Like when you have a desk for universities and a table for students, which includes the ID of the university they go to, strolling a delete on a university desk will fail if the scholars desk nonetheless consists of human beings enrolled at that college. Proper manner to do it'd be to delete the offending data first, after which delete the college in query. Quick manner could involve strolling SET foreign_key_checks=zero before the DELETE command, and placing the parameter returned to at least one after the DELETE is done. If your overseas key changed into formulated with ON DELETE CASCADE, the facts in dependent tables could be eliminated routinely.

PHP Interview Questions
Question 13. When Would You Use Order By In Delete Statement?

Answer :

When you’re now not deleting by using row ID. Such as in DELETE FROM techpreparation_com_questions ORDER BY timestamp LIMIT 1.

WordPress Tutorial
Question 14. How Can You See All Indexes Defined For A Table?

Answer :

SHOW INDEX FROM techpreparation_questions;

Question 15. How Would You Change A Column From Varchar(10) To Varchar(50)?

Answer :

ALTER TABLE techpreparation_questions CHANGE techpreparation_content techpreparation_CONTENT VARCHAR(50).

WordPress Interview Questions
Question sixteen. How Would You Delete A Column?

Answer :

ALTER TABLE techpreparation_answers DROP answer_user_id.

Joomla Tutorial
Question 17. How Would You Change A Table To Innodb?

Answer :

ALTER TABLE techpreparation_questions ENGINE innodb;

Joomla Interview Questions
Question 18. When You Create A Table, And Then Run Show Create Table On It, You Occasionally Get Different Results Than What You Typed In. What Does Mysql Modify In Your Newly Created Tables?

Answer :

1. VARCHARs with period much less than 4 emerge as CHARs
2. CHARs with period extra than 3 grow to be VARCHARs.
Three. NOT NULL gets added to the columns declared as PRIMARY KEYs
4. Default values which include NULL are distinct for each column

PHP+MySQL Interview Questions
Question 19. How Do I Find Out All Databases Starting With 'tech' To Which I Have Access To?

Answer :

SHOW DATABASES LIKE ‘tech%’;

CakePHP Tutorial
Question 20. How Do You Concatenate Strings In Mysql?

Answer :

CONCAT (string1, string2, string3)

CakePHP Interview Questions
Question 21. How Do You Get A Portion Of A String?

Answer :

SELECT SUBSTR(title, 1, 10) from techpreparation_questions;

Question 22. What's The Difference Between Char_length And Length?

Answer :

The first is, clearly, the man or woman matter. The 2d is byte count number. For the Latin characters the numbers are the identical, however they’re now not the identical for Unicode and different encodings.

CodeIgniter Tutorial
Question 23. How Do You Convert A String To Utf-8?

Answer :

SELECT (techpreparation_question USING utf8);

CodeIgniter Interview Questions
Question 24. What Do % And _ Mean Inside Like Statement?

Answer :

% corresponds to zero or extra characters, _ is precisely one man or woman.

Drupal Interview Questions
Question 25. What Does + Mean In Regexp?

Answer :

At least one character. Appendix G. Regular Expressions from MySQL guide is well worth perusing earlier than the interview.

PHP7 Tutorial
Question 26. How Do You Get The Month From A Timestamp?

Answer :

SELECT MONTH(techpreparation_timestamp) from techpreparation_questions;

PHP7 Interview Questions
Question 27. How Do You Offload The Time/date Handling To Mysql?

Answer :

SELECT DATE_FORMAT(techpreparation_timestamp, ‘%Y-%m-%d’) from techpreparation_questions; A comparable TIME_FORMAT function deals with time.

MYSQL DBA Interview Questions
Question 28. How Do You Add Three Minutes To A Date?

Answer :

ADDDATE(techpreparation_publication_date, INTERVAL three MINUTE)

Question 29. What's The Difference Between Unix Timestamps And Mysql Timestamps?

Answer :

Internally Unix timestamps are saved as 32-bit integers, while MySQL timestamps are saved in a comparable way, however represented in readable YYYY-MM-DD HH:MM:SS format.

Question 30. How Do You Convert Between Unix Timestamps And Mysql Timestamps?

Answer :

UNIX_TIMESTAMP converts from MySQL timestamp to Unix timestamp, FROM_UNIXTIME converts from Unix timestamp to MySQL timestamp.

Question 31. What Are Enums Used For In Mysql?

Answer :

You can limit the feasible values that move into the table. CREATE TABLE months (month ENUM ‘January’, ‘February’, ‘March’,…); INSERT months VALUES (’April’);

Question 32. How Are Enums And Sets Represented Internally?

Answer :

As unique integers representing the powers of two, due to storage optimizations.

Question 33. How Do You Start And Stop Mysql On Windows?

Answer :

net begin MySQL, internet stop MySQL

PHP5 Interview Questions
Question 34. How Do You Start Mysql On Linux?

Answer :

/and so forth/init.D/mysql begin

Question 35. Explain The Difference Between Mysql And Mysql Interfaces In Php?

Answer :

mysql is the item-oriented model of mysql library functions.

Question 36. What's The Default Port For Mysql Server?

Answer :

3306 is the default port for MYSQL.

WordPress Interview Questions
Question 37. What Does Tee Command Do In Mysql?

Answer :

tee followed via a filename activates MySQL logging to a distinctive file. It may be stopped by means of command word.

Question 38. Can You Save Your Connection Settings To A Conf File?

Answer :

Yes, and call it ~/.My.Conf. You might need to change the permissions on the document to six hundred, in order that it’s no longer readable through others.

Question 39. How Do You Change A Password For An Existing User Via Mysqladmin?

Answer :

mysqladmin -u root -p password "newpassword"

Question forty. Use Mysqldump To Create A Copy Of The Database?

Answer :

mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.Square

Joomla Interview Questions
Question forty one. Have You Ever Used Mysql Administrator And Mysql Query Browser?

Answer :

Describe the obligations you accomplished with those gear.

Question forty two. What Are Some Good Ideas Regarding User Security In Mysql?

Answer :

There is no consumer without a password. There isn't any consumer without a user call. There is not any person whose Host column carries % (which right here suggests that the consumer can log in from everywhere inside the community or the Internet). There are as few customers as viable (in an appropriate case simplest root) who've unrestricted get admission to.

CakePHP Interview Questions
Question 43. Explain The Difference Between Myisam Static And Myisam Dynamic. ?

Answer :

In MyISAM static all the fields have constant width. The Dynamic MyISAM table might encompass fields including TEXT, BLOB, and so on. To house the records sorts with diverse lengths. MyISAM Static could be simpler to restore in case of corruption, given that even though you may lose some information, you already know exactly in which to look for the beginning of the next file.

Question forty four. What Does Myisamchk Do?

Answer :

It compressed the MyISAM tables, which reduces their disk utilization.

Question 45. Explain Advantages Of Innodb Over Myisam?

Answer :

Row-degree locking, transactions, foreign key constraints and crash healing.

Question forty six. Explain Advantages Of Myisam Over Innodb?

Answer :

Much greater conservative method to disk area control - every MyISAM table is saved in a separate report, which can be compressed then with myisamchk if wished. With InnoDB the tables are stored in tablespace, and now not a whole lot similarly optimization is possible. All facts except for TEXT and BLOB can occupy eight,000 bytes at most. No full text indexing is to be had for InnoDB. TRhe COUNT(*)s execute slower than in MyISAM due to tablespace complexity.

Question forty seven. What Are Heap Tables In Mysql?

Answer :

HEAP tables are in-memory. They are typically used for excessive-velocity brief storage. No TEXT or
BLOB fields are allowed within HEAP tables. You can best use the comparison operators = and <=>. HEAP tables do now not guide AUTO_INCREMENT. Indexes need to be NOT NULL.

Question forty eight. How Do You Control The Max Size Of A Heap Table?

Answer :

MySQL config variable max_heap_table_size.

Question forty nine. What Are Csv Tables?

Answer :

Those are the unique tables, information for which is stored into comma-separated values files. They cannot be indexed.

Question 50. Explain Federated Tables?

Answer :

Introduced in MySQL 5.Zero, federated tables permit get admission to to the tables positioned on other databases on different servers.

Question fifty one. What Is Serial Data Type In Mysql?

Answer :

BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT

SERIAL is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE

Question 52. What Happens When The Column Is Set To Auto Increment And You Reach The Maximum Value For That Table?

Answer :

It stops incrementing. It does now not overflow to 0 to save you information losses, but similarly inserts are going to provide an errors, because the key has been used already.

Question 53. Explain The Difference Between Bool, Tinyint And Bit. ?

Answer :

Prior to MySQL five.0.3: those are all synonyms. After MySQL five.Zero.3: BIT facts type can keep eight bytes of facts and ought to be used for binary information.

Question 54. Explain The Difference Between Float, Double And Real. ?

Answer :

FLOATs store floating factor numbers with eight place accuracy and take up 4 bytes.

DOUBLEs shop floating point numbers with sixteen vicinity accuracy and take in 8 bytes.

REAL is a synonym of FLOAT for now.

Question fifty five. If You Specify The Data Type As Decimal (five,2), What's The Range Of Values That Can Go In This Table?

Answer :

999.99 to -ninety nine.99. Note that with the negative wide variety the minus signal is taken into consideration one of the digits.

Question fifty six. What Happens If A Table Has One Column Defined As Timestamp?

Answer :

That subject gets the contemporary timestamp every time the row receives altered.

Question fifty seven. But What If You Really Want To Store The Timestamp Data, Such As The Publication Date Of The Article?

Answer :

Create two columns of type TIMESTAMP and use the second one for your actual records.

Question 58. Explain Data Type Timestamp Default Current_timestamp On Update Current_timestamp ?

Answer :

The column exhibits the identical behavior as a unmarried timestamp column in a desk with no other timestamp columns.

Question fifty nine. What Does Timestamp On Update Current_timestamp Data Type Do?

Answer :

On initialization places a zero in that column, on future updates places the cutting-edge value of the timestamp in.

Question 60. Explain Timestamp Default 2006:09:02 17:38:forty four? On Update Current_timestamp. ?

Answer :

A default value is used on initialization, a current timestamp is inserted on replace of the row.

Question 61. If I Created A Column With Data Type Varchar(3), What Would I Expect To See In Mysql Table?

Answer :

CHAR(three), since MySQL automatically adjusted the information kind.

Question sixty two. General Information About Mysql.

Answer :

MySQL is a totally speedy, multi-threaded, multi-user, and robust SQL (Structured Query Language) database server.

Question 63. Why Sql Is A Database Management System?

Answer :

A database is a established series of data. It can be some thing from a simple shopping listing to a photograph gallery or the good sized amounts of information in a corporate community. To upload, get entry to, and technique records stored in a computer database, you want a database management machine together with MySQL. Since computer systems are excellent at coping with big amounts of information, database management performs a primary role in computing, as stand-by myself utilities, or as parts of different packages.

Question sixty four. Why Use Mysql?

Answer :

MySQL could be very rapid, dependable, and clean to apply. If that's what you are searching out, you should deliver it a strive. MySQL also has a totally sensible set of features developed in very near cooperation with our customers. You can find a overall performance contrast of MySQL to a few other database managers on our benchmark web page. See segment 12.7 Using Your Own Benchmarks. MySQL turned into at first evolved to address very big databases an awful lot quicker than existing solutions and has been efficaciously used in quite disturbing production environments for several years. Though beneath constant development, MySQL these days offers a wealthy and very beneficial set of features. The connectivity, speed, and protection make MySQL relatively applicable for having access to databases at the Internet.

Question 65. How Mysql Optimizes Distinct ?

Answer :

DISTINCT is transformed to a GROUP BY on all columns, DISTINCT blended with ORDER BY will in many instances also want a transient table.

When combining LIMIT # with DISTINCT, MySQL will prevent as soon as it finds # unique rows.

If you don't use columns from all used tables, MySQL will forestall the scanning of the not used tables as quickly as it has determined the first match.

SELECT DISTINCT t1.A FROM t1,t2 in which t1.A=t2.A;
In the case, assuming t1 is used earlier than t2 (test with EXPLAIN), then MySQL will stop reading from t2 (for that specific row in t1) whilst the first row in t2 is discovered.

Question 66. How Mysql Optimizes Limit ?

Answer :

In a few cases MySQL will manage the question otherwise whilst you are using LIMIT # and not using HAVING:

If you are deciding on only some rows with LIMIT, MySQL will use indexes in a few cases when it commonly could opt to do a complete desk experiment.

If you use LIMIT # with ORDER BY, MySQL will end the sorting as quickly as it has determined the first # traces instead of sorting the whole table.

When combining LIMIT # with DISTINCT, MySQL will forestall as quickly as it unearths # precise rows.

In some instances a GROUP BY may be resolved by way of reading the important thing so as (or do a sort on the key) and then calculate summaries till the key price adjustments. In this situation LIMIT # will not calculate any unnecessary GROUP BY's.

As soon as MySQL has sent the primary # rows to the patron, it's going to abort the query.

LIMIT zero will continually quickly go back an empty set. This is useful to test the query and to get the column types of the result columns.

The length of temporary tables makes use of the LIMIT # to calculate how a good deal area is wanted to remedy the question.

Question sixty seven. Mysql - Speed Of Delete Queries ?

Answer :

If you need to delete all rows in the table, you must use TRUNCATE TABLE table_name. The time to delete a record is precisely proportional to the variety of indexes. To delete data more quickly, you can growth the scale of the index cache.

Question 68. What Is The Difference Between Mysql_fetch_array And Mysql_fetch_object?

Answer :

mysql_fetch_array — Fetch a result row as an associative ARRAY, a numeric array, or each
mysql_fetch_object — Fetch a result row as an OBJECT.

Question sixty nine. What Are The Different Table Present In Mysql?

Answer :

MyISAM : This is default. Based on Indexed Sequntial Access Method. The above SQL will create a MyISA desk.

ISAM : equal

HEAP : Fast data get right of entry to, but will free statistics if there may be a crash. Cannot have BLOB, TEXT & AUTO INCRIMENT fields

BDB : Supports Transactions the use of COMMIT & ROLLBACK. Slower that others.

InoDB : equal as BDB

Question 70. What Is Primary Key?

Answer :

A primary key is a single column or more than one columns described to have particular values that can be used as row identifications.

Question seventy one. What Is Foreign Key?

Answer :

A foreign secret is a unmarried column or a couple of columns defined to have values that can be mapped to a number one key in any other desk.

Question 72. What Is Index?

Answer :

An index is a unmarried column or more than one columns described to have values pre-looked after to speed up statistics retrieval speed.

Question 73. What Is Join?

Answer :

Join is facts retrieval operation that mixes rows from more than one tables beneath positive matching conditions to form a unmarried row.

Question 74. What Is Union?

Answer :

Join is information retrieval operation that combines more than one question outputs of the same shape into a unmarried output. By default the MySQL UNION removes all reproduction rows from the result set even if you don’t specific using DISTINCT after the keyword UNION.

SELECT customerNumber identity, contactLastname call
FROM customers
UNION
SELECT employeeNurrber id, firstname call
FROM personnel
identity name

103 Schmitt
112 King
114 Ferguson
119 Labrune
121 Bergulfsen

 

Question 75. What Is Isam?

Answer :

ISAM (Indexed Sequential Access Method) turned into evolved via IBM to save and retrieve facts on secondary storage systems like tapes.

Question 76. What Is Innodb?

Answer :

lnnoDB is a transaction safe garage engine advanced with the aid of Innobase Oy (an Oracle business enterprise now).

Question 77. What Is Bdb (berkeleydb)?

Answer :

BDB (BerkeleyDB) is transaction safe storage engine firstly evolved at U.C. Berkeley. It is now evolved by way of Sleepycat Software, Inc. (an Oracle business enterprise now).

Question seventy eight. What Is Csv?

Answer :

CSV (Comma Separated Values) is a document format used to save database desk contents, wherein one desk row is saved as one line in the document, and every facts area is separated with comma.

Question 79. What Is Transaction?

Answer :

A transaction is a logical unit of labor asked with the aid of a person to be implemented to the database gadgets. MySQL server introduces the transaction concept to allow users to institution one or greater SQL statements into a single transaction, so that the outcomes of all of the SQL statements in a transaction may be both all dedicated (implemented to the database) or all rolled again (undone from the database).

Question eighty. What Is Commit?

Answer :

Commit is a manner to terminate a transaction with all database adjustments to be stored permanently to the database server.

Question 81. What Is Rollback?

Answer :

Rollback is a manner to terminate a transaction with all database adjustments now not saving to the database server.

Question 82. How Many Groups Of Data Types?

Answer :

MySQL guide 3 groups of statistics sorts as indexed underneath:

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.

Question 83. What Is The Differences Between Char And Nchar?

Answer :

Both CHAR and NCHAR are constant length string information kinds. But they've the following variations:

CHARs complete name is CHARACTER.
NCHARs complete call is NATIONAL CHARACTER.
By default, CHAR uses ASCII individual set. So 1 individual is continually saved as 1 byte.
By default, NCHAR uses Unicode person set. NCHAR facts are stored in UTF8 format. So 1 character can be stored as 1 byte or upto 4 bytes.
Both CHAR and NCHAR columns are described with fixed lengths in devices of characters.
Question eighty four. How To Escape Special Characters In Sql Statements?

Answer :

There are a number of unique characters that needs to be escaped (protected), if you need to include them in a individual string. Here are some primary individual escaping regulations:

The get away man or woman () desires to be escaped as ().
The unmarried quote (‘) desires to be escaped as (‘) or (“) in unmarried-quote quoted strings.
The double quote () needs to be escaped as (“) or (““) in double-quote quoted strings.
The wild card person for a single man or woman () needs to be escaped as (_).
The wild card individual for multiple characters (%) needs to be escaped as (%).
The tab man or woman wishes to be escaped as (t).
The new line person wishes to be escaped as (n).
The carriage go back character wishes to be escaped as (r).
Question eighty five. How To Concatenate Two Character Strings?

Answer :

If you want concatenate a couple of man or woman strings into one, you want to apply the CONCAT() characteristic. Here are a few accurate examples:

SELECT CONCAT(’Welcome’,’ to’) FROM DUAL;
Welcome to
SELECT CONCAT(wj’,’center’,’.Com’) FROM DUAL;
wisdomjobs.Com
Question 86. How To Enter Characters As Hex Numbers?

Answer :

If you want to go into characters as HEX numbers, you could quote HEX numbers with single fees and a prefix of (X), or just prefix HEX numbers with (Ox). A HEX number string might be routinely transformed right into a individual string, if the expression context is a string. Here are a few correct examples:

SELECT X313233’ FROM DUAL;
123
SELECT 0x414243 FROM DUAL;
ABC
Question 87. How To Enter Boolean Values In Sql Statements?

Answer :

If you need to enter Boolean values in SQL statements, you use (TRUE), (FALSE), (proper), or (false). Here are a few exact examples:

SELECT TRUE, true, FALSE, fake FROM DUAL;
Question 88. How To Convert Numeric Values To Character Strings?

Answer :

You can convert numeric values to character strings with the aid of the use of the CAST(fee AS CHAR) characteristic as shown in the following examples:

SELECT CAST(4123.45700 AS CHAR) FROM DUAL;
4123.45700
Question 89. How To Get Rid Of The Last 2 zero's?

Answer :

SELECT CAST(4.12345700E+3 AS CHAR) FROM DUAL;
4123.457
SELECT CAST(1/three AS CHAR);
0.3333

Question ninety. How To Use In Conditions?

Answer :

An IN situation is single value once more a list of values. It returns TRUE, if the required fee is inside the list. Otherwise, it returns FALSE. Some examples are :

SELECT 3 IN (1,2,three,four,5) FROM DUAL;
1
SELECT 3 NOT IN (1,2,3,four,five) FROM DUAL;
zero
SELECT Y’ IN (‘F’,’Y’,I) FROM DUAL; 
1
Question ninety one. How To Use Like Conditions?

Answer :

A LIKE condition is likewise called pattern patch. There are three important policies on the use of LIKE condition:

is used inside the pattern to in shape any individual person.
% is used in the pattern to match any 0 or greater characters.
ESCAPE clause is used to provide the escape man or woman inside the pattern.
Question 92. How To Present A Past Time In Hours, Minutes And Seconds?

Answer :

If you want display an editorial changed into posted “n hours n mins and n seconds ago’, you may use the TIMEDIFF(NOWO, pastTime) feature as shown inside the following are:

SELECT TIMEDIFF(NOWO, ‘2006-07-01 04:09:forty nine’) FROM DUAL;
06:42:fifty eight
SELECT TIM E_FORMAT(TI M EDI FF( NOWO, ‘2006-06-30 04:09:forty nine’), 
 ‘%H hours, %i mins and %s seconds ago.’) FROM DUAL;
30 hours, 45 minutes and 22 seconds in the past.
Question 93. How To Add A New Column To An Existing Table In Mysql?

Answer :

ALTER TABLE tip ADD COLUMN writer VARCHAR(40);
Query OK, 1 row affected (0.18 sec)
Records: 1 Duplicates: zero Warnings: 0

Question ninety four. How To Delete An Existing Column In A Table?

Answer :

ALTER TABLE tip DROP COLUMN create_date;
Query OK, 1 row affected (0.48 sec)
Records: 1 Duplicates: zero Warnings: 0

Question 95. How To Rename An Existing Column In A Table?

Answer :

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

Question ninety six. How To Rename An Existing Table In Mysql?

Answer :

ALTER TABLE tip RENAME TO faq;

Question ninety seven. How To Create A Table Index In Mvsql?

Answer :

If you've got a desk with a plenty of rows, and you understand that one of the columns might be used often as a search criteria, you can upload an index for that column to improve the quest performance. To upload an index, you could use the “CREATE INDEX” declaration as shown within the following script:

<pre>mysql> CREATE TABLE tip (identity INTEGER PRIMARY KEY,
subject VARCHAR(eighty) NOT NULL, 
description VARCHAR(256) NOT NULL, 
create_date DATE NULL);  Query OK, 
0 rows affected (zero.08 sec)</pre>
mysql> CREATE INDEX tip_subject ON tip(situation);
Query OK,
0 rows affected (0.19 sec)
Records: zero Duplicates: zero Warnings: 0
Question 98. How To Get A List Of Indexes Of An Existing Table?

Answer :

If you want to see the index you have just created for an current table, you can use the “SHOW INDEX FROM tableName” command to get a listing of all indexes in a given table.

Question ninety nine. How To Drop An Existing Index In Mysql?

Answer :

If you don’t want an current index any greater, you need to delete it with the “DROP INDEX indexName ON tableName” declaration. Here is an example SQL script :

mysqi> DROP INDEX tip_subject ON tip;
Query OK, zero rows affected (0.13 sec)
Records: 0 Duplicates: 0 Warnings: zero
Question a hundred. How To Drop An Existing View In Mysql?

Answer :

If you've got an present view, and also you dont want it anymore, you could delete it by using the usage of the “DROP VIEW viewName” declaration

Question a hundred and one. How To Create A New View In Mysql?

Answer :

You can create a brand new view based on one or extra existing tables through the use of the

“CREATE VIEW viewName AS selectStatement” .

Question 102. How To Increment Dates By 1111 Mysql?

Answer :

If you have a date, and also you need to increment it by 1 day, you can use the DATE_ADD(date, INTERVAL 1 DAY) feature. You can also use the date c program languageperiod upload operation as “date + INTERVAL 1 DAY.




CFG