1. What’s MySQL?
MySQL the most popular Open Source SQL database management system, is developed, distributed, and supported by MySQL AB. MySQL AB is a commercial company, founded by the MySQL developers, that builds its business by providing services around the MySQL database management system.
2. Why use the MySQL Database Server?
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.
3. What is the technical features of MySQL Server?
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).
4. What are the column comparisons operators?
The = , ‹›, ‹=, ‹, ›=, ›,‹‹,››, ‹=›, AND, OR, or LIKE operators may be used in column comparisons to the left of the FROM in SELECT statements.
5. How do you get the number of rows affected by query?
SELECT COUNT (user_id) FROM users;
6. What are HEAP tables in MySQL?
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.
7. How do you return the a hundred books starting from 25th?
SELECT book_title FROM books LIMIT 25, 100;
8. How would you write a query to select all teams that won either 2, 4, 6 or 8 games?
SELECT team_name FROM teams WHERE team_won IN (2, 4, 6, 8).
9. What is the default port for MySQL Server?
The default port is 3306.
10. How would you select all the users, whose phone number is null?
SELECT user_name FROM users WHERE ISNULL(user_phonenumber);
11. What are ENUMs used for in MySQL?
You can limit the possible values that go into the table.
CREATE TABLE months (month ENUM ’January’, ’February’, ’March’,); INSERT months VALUES (’April’).
12. What are the advantages of Mysql comparing with oracle?
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.
13. What is the difference between CHAR_LENGTH and LENGTH?
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.
14. How are ENUMs and SETs represented internally?
As unique integers representing the powers of two, due to storage optimizations.
15. How do you change a password for an existing user via mysqladmin?
mysqladmin -u root -p password "newpassword"
16. If the value in the column is repeatable, how do you find out the unique values?
SELECT DISTINCT user_firstname FROM users;
17. Explain the difference between FLOAT, DOUBLE and REAL?
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.
18. How do you get the current version of mysql?
SELECT VERSION();
19. Is Mysql query has LETTERCASE?
No.
Ex :
SELECT VERSION(), CURRENT_DATE;
select version(), current_date;
SeLeCt vErSiOn(), current_DATE;
20. What is the LIKE?
A LIKE pattern match, which succeeds only if the pattern matches the entire value.
21. Differentiate the LIKE and REGEXP operators?
SELECT * FROM pet WHERE name REGEXP "^b";
SELECT * FROM pet WHERE name LIKE "%b";
22. What are the String types are available for a column?
The string types are CHAR, VARCHAR, BLOB, TEXT, ENUM, and SET.
23. What is the REGEXP?
A REGEXP pattern match succeed if the pattern matches anywhere in the value being tested.
24. What is the difference between CHAR AND VARCHAR?
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.
25. How quoting and escaping work in SELECT QUERY?
SELECT ‘hello’, ‘“hello”’,‘““hello””’, ‘hel‘‘lo’, ‘\‘hello’.
26. What is the difference between BLOB AND TEXT?
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.
27. How we get Sum of column?
SELECT SUM(*) FROM [table name];
28. How do you get current user in mysql?
SELECT USER();
29. How would you change a table to InnoDB?
ALTER TABLE name_file ENGINE innodb;
30. How do you concatenate strings in MySQL?
CONCAT (string1, string2, string3)
31. what is difference between primary key and candidate key?
Primary Key
- are used to uniquely identify each row of the table. A table can have only one primary Key.
Candidate Key
- primary key is a candidate key. There is no difference. By common convention one candidate key is designated as a “primary” one and that key is used for any foreign key references.
32. How do you get the month from a timestamp?
SELECT MONTH(january_timestamp) from tablename;
33. What do % and _ mean inside LIKE statement?
% corresponds to 0 or more characters, _ is exactly one character.
34. If you specify the data type as DECIMAL (5,2), what’s the range of values that can go in this table?
999.99 to -99.99. Note that with the negative number the minus sign is considered one of the digits.
35. How do you get the current date in Mysql?
SELECT CURRENT_DATE();
36. What is the difference between mysql_fetch_array and mysql_fetch_object?
mysql_fetch_array(): - returns a result row as a associated array, regular array from database.
mysql_fetch_object: - returns a result row as object from database.
37. 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?
SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS();
38. What does this query mean: SELECT user_name, user_isp FROM users LEFT JOIN isps USING (user_id)?
It’s equivalent to saying SELECT user_name, user_isp FROM users LEFT JOIN isps WHERE users.user_id=isps.user_id
39. How do you display the list of database in mysql?
SHOW DATABASES;
40. How do you display the structure of the table?
DESCRIBE table_name;
41. How do you find out which auto increment was assigned on the last insert?
SELECT LAST_INSERT_ID() will return the last value assigned by the auto_increment function. Note that you don’t have to specify the table name.
42. What does TIMESTAMP ON UPDATE CURRENT_TIMESTAMP data type do?
On initialization places a zero in that column, on future updates puts the current value of the timestamp in.
43. How many drivers in Mysql?
There are eleven drivers in MYSQL .Six of them from MySQL AB and five by MYSQL Communities.They are
PHP Driver
ODBC Driver
JDBC Driver
ado.net5.mxj
CAPI1PHP DRIVER
PERL DRIVER
PYTHON DRIVER
RUBY DRIVER
C WRAPPER
44. How do you run batch mode in mysql?
mysql < batch-file >;
mysql < batch-file > mysql.out
45. What Storage Engines do you use in MySQL?
Storage engines used to be called table types.
Data in MySQL is stored in files (or memory) using a variety of different techniques. Each of these techniques employs different storage mechanisms, indexing facilities, locking levels and ultimately provides a range of different functions and capabilities. By choosing a different technique you can gain additional speed or functionality benefits that will improve the overall functionality of your application.
46. Where MyISAM table is stored?
Each MyISAM table is stored on disk in three files.
The ‘.frm’ file stores the table definition.
The data file has a ‘.MYD’ (MYData) extension.
The index file has a ‘.MYI’ (MYIndex) extension
47. Define Primary key?
MYSQL allows only one primary key. A primary key is used to uniquely identify each row in a table. It can either be part of the actual record itself.A primary key can consist of one or more fields on a table. When multiple fields are used as a primary key, they are called a composite key.
MySQL the most popular Open Source SQL database management system, is developed, distributed, and supported by MySQL AB. MySQL AB is a commercial company, founded by the MySQL developers, that builds its business by providing services around the MySQL database management system.
2. Why use the MySQL Database Server?
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.
3. What is the technical features of MySQL Server?
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).
4. What are the column comparisons operators?
The = , ‹›, ‹=, ‹, ›=, ›,‹‹,››, ‹=›, AND, OR, or LIKE operators may be used in column comparisons to the left of the FROM in SELECT statements.
5. How do you get the number of rows affected by query?
SELECT COUNT (user_id) FROM users;
6. What are HEAP tables in MySQL?
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.
7. How do you return the a hundred books starting from 25th?
SELECT book_title FROM books LIMIT 25, 100;
8. How would you write a query to select all teams that won either 2, 4, 6 or 8 games?
SELECT team_name FROM teams WHERE team_won IN (2, 4, 6, 8).
9. What is the default port for MySQL Server?
The default port is 3306.
10. How would you select all the users, whose phone number is null?
SELECT user_name FROM users WHERE ISNULL(user_phonenumber);
11. What are ENUMs used for in MySQL?
You can limit the possible values that go into the table.
CREATE TABLE months (month ENUM ’January’, ’February’, ’March’,); INSERT months VALUES (’April’).
12. What are the advantages of Mysql comparing with oracle?
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.
13. What is the difference between CHAR_LENGTH and LENGTH?
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.
14. How are ENUMs and SETs represented internally?
As unique integers representing the powers of two, due to storage optimizations.
15. How do you change a password for an existing user via mysqladmin?
mysqladmin -u root -p password "newpassword"
16. If the value in the column is repeatable, how do you find out the unique values?
SELECT DISTINCT user_firstname FROM users;
17. Explain the difference between FLOAT, DOUBLE and REAL?
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.
18. How do you get the current version of mysql?
SELECT VERSION();
19. Is Mysql query has LETTERCASE?
No.
Ex :
SELECT VERSION(), CURRENT_DATE;
select version(), current_date;
SeLeCt vErSiOn(), current_DATE;
20. What is the LIKE?
A LIKE pattern match, which succeeds only if the pattern matches the entire value.
21. Differentiate the LIKE and REGEXP operators?
SELECT * FROM pet WHERE name REGEXP "^b";
SELECT * FROM pet WHERE name LIKE "%b";
22. What are the String types are available for a column?
The string types are CHAR, VARCHAR, BLOB, TEXT, ENUM, and SET.
23. What is the REGEXP?
A REGEXP pattern match succeed if the pattern matches anywhere in the value being tested.
24. What is the difference between CHAR AND VARCHAR?
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.
25. How quoting and escaping work in SELECT QUERY?
SELECT ‘hello’, ‘“hello”’,‘““hello””’, ‘hel‘‘lo’, ‘\‘hello’.
26. What is the difference between BLOB AND TEXT?
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.
27. How we get Sum of column?
SELECT SUM(*) FROM [table name];
28. How do you get current user in mysql?
SELECT USER();
29. How would you change a table to InnoDB?
ALTER TABLE name_file ENGINE innodb;
30. How do you concatenate strings in MySQL?
CONCAT (string1, string2, string3)
31. what is difference between primary key and candidate key?
Primary Key
- are used to uniquely identify each row of the table. A table can have only one primary Key.
Candidate Key
- primary key is a candidate key. There is no difference. By common convention one candidate key is designated as a “primary” one and that key is used for any foreign key references.
32. How do you get the month from a timestamp?
SELECT MONTH(january_timestamp) from tablename;
33. What do % and _ mean inside LIKE statement?
% corresponds to 0 or more characters, _ is exactly one character.
34. If you specify the data type as DECIMAL (5,2), what’s the range of values that can go in this table?
999.99 to -99.99. Note that with the negative number the minus sign is considered one of the digits.
35. How do you get the current date in Mysql?
SELECT CURRENT_DATE();
36. What is the difference between mysql_fetch_array and mysql_fetch_object?
mysql_fetch_array(): - returns a result row as a associated array, regular array from database.
mysql_fetch_object: - returns a result row as object from database.
37. 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?
SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS();
38. What does this query mean: SELECT user_name, user_isp FROM users LEFT JOIN isps USING (user_id)?
It’s equivalent to saying SELECT user_name, user_isp FROM users LEFT JOIN isps WHERE users.user_id=isps.user_id
39. How do you display the list of database in mysql?
SHOW DATABASES;
40. How do you display the structure of the table?
DESCRIBE table_name;
41. How do you find out which auto increment was assigned on the last insert?
SELECT LAST_INSERT_ID() will return the last value assigned by the auto_increment function. Note that you don’t have to specify the table name.
42. What does TIMESTAMP ON UPDATE CURRENT_TIMESTAMP data type do?
On initialization places a zero in that column, on future updates puts the current value of the timestamp in.
43. How many drivers in Mysql?
There are eleven drivers in MYSQL .Six of them from MySQL AB and five by MYSQL Communities.They are
PHP Driver
ODBC Driver
JDBC Driver
ado.net5.mxj
CAPI1PHP DRIVER
PERL DRIVER
PYTHON DRIVER
RUBY DRIVER
C WRAPPER
44. How do you run batch mode in mysql?
mysql < batch-file >;
mysql < batch-file > mysql.out
45. What Storage Engines do you use in MySQL?
Storage engines used to be called table types.
Data in MySQL is stored in files (or memory) using a variety of different techniques. Each of these techniques employs different storage mechanisms, indexing facilities, locking levels and ultimately provides a range of different functions and capabilities. By choosing a different technique you can gain additional speed or functionality benefits that will improve the overall functionality of your application.
46. Where MyISAM table is stored?
Each MyISAM table is stored on disk in three files.
The ‘.frm’ file stores the table definition.
The data file has a ‘.MYD’ (MYData) extension.
The index file has a ‘.MYI’ (MYIndex) extension
47. Define Primary key?
MYSQL allows only one primary key. A primary key is used to uniquely identify each row in a table. It can either be part of the actual record itself.A primary key can consist of one or more fields on a table. When multiple fields are used as a primary key, they are called a composite key.
No comments:
Post a Comment