| Q. What's MySQL ? |
| A. MySQL (pronounced "my ess cue el") is an open source relational database management system (RDBMS) that uses Structured Query Language (SQL), the most popular language for adding, accessing, and processing data in a database. Because it is open source, anyone can download MySQL and tailor it to their needs in accordance with the general public license. MySQL is noted mainly for its speed, reliability, and flexibility. ... |
| |
| Q. What is DDL, DML and DCL ? |
| A. 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. |
| |
| Q. How do you get the number of rows affected by query? |
| A. SELECT COUNT (user_id) FROM users would only return the number of user_id’s. |
| |
| Q. If the value in the column is repeatable, how do you find out the unique values? |
| A. Use DISTINCT in the query, such as SELECT DISTINCT user_firstname FROM users; You can also ask for a number of distinct values by saying SELECT COUNT (DISTINCT user_firstname) FROM users; |
| |
| Q. How do you return the a hundred books starting from 25th? |
| A. SELECT book_title FROM books LIMIT 25, 100. The first number in LIMIT is the offset, the second is the number. |
| |
| Q. 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? |
| A. SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS(); The second query (not that COUNT() is never used) will tell you how many results there’re total, so you can display a phrase "Found 13,450,600 results, displaying 1-10". Note that FOUND_ROWS does not pay attention to the LIMITs you specified and always returns the total number of rows affected by query. |
| |
| Q. How would you write a query to select all teams that won either 2, 4, 6 or 8 games? |
| A. SELECT team_name FROM teams WHERE team_won IN (2, 4, 6, 8) |
| |
| Q. How would you select all the users, whose phone number is null? |
| A. SELECT user_name FROM users WHERE ISNULL(user_phonenumber); |
| |
| Q. Why use the MySQL Database Server? |
| A. The MySQL Database Server is very fast, reliable, and easy to use. it is possible for anyone to use and modify the software. Anybody can download the MySQL software from the Internet and use it without paying anything. |
| |
| Q. What is the technical features of MySQL Server? |
| A. The MySQL Database Software is a client/server system that consists of a multi-threaded SQL server that supports different backends, several different client programs and libraries, administrative tools, and a wide range of application programming interfaces (APIs). |
| |
| Q. What are the column comparisons operators? |
| A. The = , ‹›, ‹=, ‹, ›=, ›,‹‹,››, ‹=›, AND, OR, or LIKE operators may be used in column comparisons to the left of the FROM in SELECT statements. |
| |
| Q. How do you get the number of rows affected by query? |
| A. SELECT COUNT (user_id) FROM users; |
| |
| Q. What are HEAP tables in MySQL? |
A. HEAP tables are in-memory. They are usually used for high-speed temporary storage.
- No TEXT or BLOB fields are allowed within HEAP tables.
- You can only use the comparison operators = and ‹=›.
- HEAP tables do not support AUTO_INCREMENT.
- Indexes must be NOT NULL.
|
| |
| Q. How do you return the a hundred books starting from 25th? |
| A. SELECT book_title FROM books LIMIT 25, 100; |
| |
| Q. What are ENUMs used for in MySQL? |
| A. You can limit the possible values that go into the table. CREATE TABLE months (month ENUM ’January’, ’February’, ’March’,); INSERT months VALUES (’April’). |
| |
| Q.What are the advantages of Mysql comparing with oracle? |
| A. MySql is Open source, which can be available any time. Provides Gui with Command Prompt. Supports the administration using MySQL Admin,MySQL Query Browser.Oracle is best database ever in Software development. |
| |
| Q. What is the difference between CHAR_LENGTH and LENGTH? |
| A. The first is, naturally, the character count. The second is byte count. For the Latin characters the numbers are the same, but they’re not the same for Unicode and other encodings. |
| |
| Q. How are ENUMs and SETs represented internally? |
| A. As unique integers representing the powers of two, due to storage optimizations. |
| |
| Q. How do you change a password for an existing user via mysqladmin? |
| A. mysqladmin -u root -p password "newpassword" |
| |
| Q. If the value in the column is repeatable, how do you find out the unique values? |
| A. SELECT DISTINCT user_firstname FROM users; |
| |
| Q. Explain the difference between FLOAT, DOUBLE and REAL? |
| A. FLOATs store floating point numbers with 8 place accuracy and take up 4 bytes. DOUBLEs store floating point numbers with 16 place accuracy and take up 8 bytes. REAL is a synonym of FLOAT for now. |
| |
| Q. How do you get the current version of mysql? |
| A. SELECT VERSION(); |
| |
| Q. Is Mysql query has LETTERCASE? |
A.
- No.
- Ex :
- SELECT VERSION(), CURRENT_DATE;
- select version(), current_date;
- SeLeCt vErSiOn(), current_DATE;
|
| |
| Q. What is the LIKE? |
| A. A LIKE pattern match, which succeeds only if the pattern matches the entire value. |
| |
| Q. Differentiate the LIKE and REGEXP operators? |
A.
- SELECT * FROM pet WHERE name REGEXP "^b";
- SELECT * FROM pet WHERE name LIKE "%b";
|
| |
| Q. What are the String types are available for a column? |
| A. The string types are CHAR, VARCHAR, BLOB, TEXT, ENUM, and SET. |
| |
| Q. What is the REGEXP? |
| A. A REGEXP pattern match succeed if the pattern matches anywhere in the value being tested. |
| |
| Q. What is the difference between CHAR AND VARCHAR? |
| A. The CHAR and VARCHAR types are similar, but differ in the way they are stored and retrieved. The length of a CHAR column is fixed to the length that you declare when you create the table. The length can be any value between 1 and 255. When CHAR values are stored, they are right-padded with spaces to the specified length. When CHAR values are retrieved, trailing spaces are removed. |
| |
| Q. How quoting and escaping work in SELECT QUERY? |
| A. SELECT ‘hello’, ‘“hello”’,‘““hello””’, ‘hel‘‘lo’, ‘\‘hello’. |
| |
| Q.What is the difference between BLOB AND TEXT? |
| A. A BLOB is a binary large object that can hold a variable amount of data. The four BLOB types TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB differ only in the maximum length of the values they can hold. The four TEXT types TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT correspond to the four BLOB types and have the same maximum lengths and storage requirements. The only difference between BLOB and TEXT types is that sorting and comparison is performed in case-sensitive fashion for BLOB values and case-insensitive fashion for TEXT values. In other words, a TEXT is a case-insensitive BLOB. |
| |
| Q. How we get Sum of column? |
| A. mysql> SELECT * FROM tablename; |
| |
| Q.How do you get current user in mysql? |
| A. SELECT USER(); |
| |