Intel MySQL Most Frequently Asked Latest Interview Questions Answers

What Is Ddl, Dml And Dcl ?

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.

How Do You Get The Number Of Rows Affected By Query?

SELECT COUNT (user_id) FROM users would only return the number of user_id’s.

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

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;

How Do You Return The A Hundred Books Starting From 25th?

SELECT book_title FROM books LIMIT 25, 100. The first number in LIMIT is the offset, the second is the number.

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(); 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.
Intel MySQL Most Frequently Asked Latest Interview Questions Answers
Intel MySQL Most Frequently Asked Latest Interview Questions Answers

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)

How Would You Select All The Users, Whose Phone Number Is Null?

SELECT user_name FROM users WHERE ISNULL(user_phonenumber);

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

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.

What Does -i-am-a-dummy Flag To Do When Starting Mysql?

Makes the MySQL engine refuse UPDATE and DELETE commands where the WHERE clause is not present.

On Executing The Delete Statement I Keep Getting The Error About Foreign Key Constraint Failing. What Do I Do?

What it means is that so of the data that you’re trying to delete is still alive in another table. Like if you have a table for universities and a table for students, which contains the ID of the university they go to, running a delete on a university table will fail if the students table still contains people enrolled at that university. Proper way to do it would be to delete the offending data first, and then delete the university in Question. Quick way would involve running SET foreign_key_checks=0 before the DELETE command, and setting the parameter back to 1 after the DELETE is done. If your foreign key was formulated with ON DELETE CASCADE, the data in dependent tables will be removed automatically.

When Would You Use Order By In Delete Statement?

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

How Can You See All Indexes Defined For A Table?

SHOW INDEX FROM techpreparation_Questions;

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

ALTER TABLE techpreparation_Questions CHANGE techpreparation_content techpreparation_CONTENT VARCHAR(50).

How Would You Delete A Column?

ALTER TABLE techpreparation_s DROP _user_id.

How Would You Change A Table To Innodb?

ALTER TABLE techpreparation_Questions ENGINE innodb;

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

How Do I Find Out All Databases Starting With 'tech' To Which I Have Access To?

SHOW DATABASES LIKE ‘tech%’;

How Do You Concatenate Strings In Mysql?

CONCAT (string1, string2, string3).

Post a Comment

Previous Post Next Post