Close   

Admin and announcement forums

    30 Mar 2008
Questions about database (MySql) i come across during my interviews  
kumar rakesh
create and manage free online surveys with unlimited responses
Online surveys are now basic requirement of everyone who want to review there products or to make studies about anything. But finding a solution who can provide esurveys efficiently is really a big pain. creating an online survey with inefficient tool as irritating and getting survey conducted with limitations on responses is even worse.
cont..
    30 Mar 2008
Questions about database (MySql) i come across during my interviews  
kumar rakesh
practice interviews and prepare for interviews
in todays changing world every one want to increase there salaries very quickly.
Changes your employer is an very efficient solution for this. But changing employer and company is not so easy.

cont..

Viewed 129 times
Total posts : 0

    29 Nov 2007
Questions about database (MySql) i come across during my interviews  
Sujan Sen
His other forums
Questions about database (MySql) i come across during my interviews
  1. What is DDL, DML and DCL?
    1.  - 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.
  2. How do you get the number of rows affected by query? -
    1. SELECT COUNT (name) FROM users would only return the number of names

  3. If the value in the column is repeatable, how do you find out the unique values? -
    1. To get unique records we can use DISTINCT in query, such as SELECT DISTINCT name FROM users.
    2. To count distinct records you can use  SELECT COUNT (DISTINCT name) FROM users.
  4. How do you return the a x books starting from yth?
    1.  SELECT book_title FROM books LIMIT y, x. The first number in LIMIT is the offset, the second is the number.
  5. How would you write a query to select all teams that won either 2, 4, 6 or 8 games?
    1. SELECT team_name FROM teams WHERE team_won IN (2, 4, 6, 8)
  6. How would you select all the users, whose phone number is null?
    1. SELECT user_name FROM users WHERE ISNULL(user_phonenumber);
  7. What does this query mean: SELECT name, isps.id FROM users LEFT JOIN isps USING (id)
    1.  It’s equivalent to saying SELECT user_name, user_isp FROM users LEFT JOIN isps WHERE users.id=isps.id
  8. How to find last insert_id?
    1. 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.
  9. When would you use ORDER BY in DELETE statement?
    1. When you’re not deleting by row ID. Such as in DELETE FROM techinterviews_com_questions ORDER BY timestamp LIMIT 1. This will delete the most recently posted question in the table techinterviews_com_questions.
  10. How can you see all indexes defined for a table? 
    1. SHOW INDEX FROM techinterviews_questions;
  11. How would you change a column from VARCHAR(10) to VARCHAR(50)?
    1.  ALTER TABLE techinterviews_questions CHANGE techinterviews_content techinterviews_CONTENT VARCHAR(50).
  12. How would you delete a column?
    1.  ALTER TABLE techinterviews_answers DROP answer_user_id.
  13. 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?
    1. VARCHARs with length less than 4 become CHARs
    2. CHARs with length more than 3 become VARCHARs.
    3. NOT NULL gets added to the columns declared as PRIMARY KEYs
    4. Default values such as NULL are specified for each column
  14. How do I find out all databases starting with ‘tech’ to which I have access to?
    1.  SHOW DATABASES LIKE ‘tech%’;
  15. How do you concatenate strings in MySQL?
    1. CONCAT (string1, string2, string3)
  16. How do you get a portion of a string? 
    1. SELECT SUBSTR(title, 1, 10) from techinterviews_questions;
  17. What’s the difference between CHAR_LENGTH and LENGTH?
    1. 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.
  18. How do you convert a string to UTF-8?
    1.  SELECT (techinterviews_question USING utf8);
  19. What does + mean in REGEXP?
    1. It will match previous character at least once
  20. How do you get the year from a timestamp?
    1. SELECT YEAR(timestamp) from users;
  21. How do you offload the time/date handling to MySQL? 
    1.  SELECT DATE_FORMAT(timestamp, ‘%Y-%m-%d’) from questions;
    2. A similar TIME_FORMAT function formats time.
  22. What’s the difference between Unix timestamps and MySQL timestamps?
    1.  Internally Unix timestamps are stored as 32-bit integers, while MySQL timestamps are stored in a similar manner, but represented in readable YYYY-MM-DD HH:MM:SS format.
  23. How do you convert between Unix timestamps and MySQL timestamps?
    1. UNIX_TIMESTAMP converts from MySQL timestamp to Unix timestamp,
    2. FROM_UNIXTIME converts from Unix timestamp to MySQL timestamp.
  24. What are ENUMs used for in MySQL?
    1. It limits the allowed values for the field
Questions about database (MySql) i come across during my interviews Questions about database (MySql) i come across during my interviews
Questions about database (MySql) i come across during my interviews Be first to reply this discussion.
Questions about database (MySql) i come across during my interviews Questions about database (MySql) i come across during my interviews Questions about database (MySql) i come across during my interviews

Login to participate in forums
jump to :
Post reply on this forum

Comment on this forum
Name :
Email :
Comments :
Legends
Questions about database (MySql) i come across during my interviews Forums tagged Questions about database (MySql) i come across during my interviews Forums tagged. But locked for further reply
="Questions Forums locked. can not accept further replies Questions about database (MySql) i come across during my interviews General forum