21. Which is the library file that contains various portability macros and definitions?
Answer & Solution
Let's break down the options: * Option A: my_global.h This file holds global settings and variables for MySQL, influencing how the database operates. * Option B: my_sys.h This file is the crucial one! It contains portability macros and definitions, meaning it helps MySQL adapt to different operating system environments. * Option C: mysql.h This file is the main header file for working with MySQL. It provides the core functions and structures you need to interact with the database. * Option D: my_local.h This file is used for settings that are specific to a particular operating system. Therefore, the correct answer is Option B: my_sys.h. It's the file dedicated to making MySQL compatible with different platforms.
22. "COUNT" keyword belongs to which categories in Mysql?
Answer & Solution
Let's break down the options:
Option A: Aggregate functions - These are special functions in MySQL that perform calculations on a group of rows, like finding the total, average, or maximum value.
Option B: Operators - Operators are symbols like +, -, *, /, and = that perform specific actions on data.
Option C: Clauses - Clauses are parts of a SQL statement that specify conditions or actions. For example, the "WHERE" clause tells MySQL which rows to use.
Now, let's look at the keyword "COUNT". You use "COUNT" to count the number of rows in a table or the number of rows that meet certain criteria. This sounds a lot like what aggregate functions do!
So the answer is Option A: Aggregate functions.
23. Which clause can be used to sort string values according to a specific collation?
Answer & Solution
Let's break down the options:
Option A: SORT
The SORT clause is used to order the results of a query. It's a general sorting mechanism.
Option B: GROUP
The GROUP clause is used to combine rows with the same value into groups. It doesn't directly deal with sorting.
Option C: FILTER
There's no FILTER clause in MySQL.
Option D: COLLATE
The COLLATE clause is the key here! It specifically tells MySQL how to compare string values based on a particular collation. Collations are rules that determine how characters are sorted and compared.
So the answer is Option D: COLLATE
24. Consider a database name "db_name" whose attributes are intern_id (primary key), subject.
Intern_id= {1, 2, 3, 4, 5, 6}
Subject= {sql, oop, sql, oop, c, c++}
If these are one to one relation then what will be the output of the following MySQL statement?
SELECT intern_id
FROM db_name
WHERE subject NOT IN (c, c++);
Intern_id= {1, 2, 3, 4, 5, 6}
Subject= {sql, oop, sql, oop, c, c++}
If these are one to one relation then what will be the output of the following MySQL statement?
SELECT intern_id
FROM db_name
WHERE subject NOT IN (c, c++);
Answer & Solution
We have a database called "db_name" which stores information about interns and their subjects.
Each intern has a unique intern_id (this acts as the primary key, meaning each intern_id is unique), and they are associated with a single subject.
The "NOT IN" clause in SQL helps us find records that do not match the values listed within the parentheses.
In this case, the query wants to find intern_id values where the subject is NOT "c" or "c++".
Looking at our data:
- intern_id 1 has "sql" as the subject.
- intern_id 2 has "oop" as the subject.
- intern_id 3 has "sql" as the subject.
- intern_id 4 has "oop" as the subject.
- intern_id 5 has "c" as the subject.
- intern_id 6 has "c++" as the subject.
Therefore, the intern_id values that satisfy the condition subject NOT IN ("c", "c++") are {1, 2, 3, 4}.
So, the correct answer is None of the mentioned.
25. Which statement is used to delete an existing row from the table?
Answer & Solution
Let's break down the options:
Option A: DELETE - This is the correct answer. The DELETE statement is used to remove rows from a table.
Option B: WHERE - The WHERE clause is used with DELETE to specify which rows to delete. It's like a filter.
Option C: MODIFY - MODIFY is used to change the structure of a table, like adding a new column or changing an existing one. It doesn't remove rows.
Option D: None of the mentioned - This is incorrect because DELETE is the command used to remove rows.
Example:
To delete a row from a table called "students" where the student's ID is 123, you would use:
DELETE FROM students WHERE id = 123;
26. In the following MySQL command how many rows will be updated?
UPDATE person
SET lname=’s’,
Fname=’p’,
WHERE person_id<10;
/* person_id is a primary key */
UPDATE person
SET lname=’s’,
Fname=’p’,
WHERE person_id<10;
/* person_id is a primary key */
Answer & Solution
UPDATE person: This tells us we're modifying data within the 'person' table.
SET lname='s', Fname='p': This part assigns the value 's' to the 'lname' column and 'p' to the 'fname' column for each row that meets the criteria.
WHERE person_id<10: This is a condition that specifies which rows will be affected. It says that only rows where the value in the 'person_id' column is less than 10 should be updated.
/* person_id is a primary key */: This comment tells us that 'person_id' is a primary key. A primary key uniquely identifies each row in a table.
Since a primary key can't have duplicate values, having a 'person_id' less than 10 means there are at least 10 rows in the table.
Therefore, the correct answer is: Option A: 0-9
The command will update all rows in the 'person' table where the 'person_id' is less than 10. The exact number of rows updated will depend on how many rows have a 'person_id' less than 10.
27. A stored program associated with a schedule is . . . . . . . .
Answer & Solution
Option A: Trigger - Triggers are special pieces of code that automatically run after something happens in the database, like inserting, updating, or deleting data. They are not associated with schedules.
Option B: Event - Events are the correct answer! They are like scheduled tasks in MySQL. You can set them to run specific code at certain times or intervals. Think of them as automated reminders for the database.
Option C: Stored function - Functions are blocks of reusable code that can be called from other queries. They don't have any built-in scheduling abilities.
Option D: Stored procedure - Procedures are also reusable blocks of code that can be called, but they don't have automatic scheduling features either.
In short, the answer is Option B: Event. Events are designed to execute stored programs based on a defined schedule.
28. In MySQL databases, the structure representing the organizational views of the entire databases is . . . . . . . .
Answer & Solution
Option A: Schema - This is the correct answer! A schema defines the structure of your database. It's like a blueprint that outlines all the tables, columns, and relationships within your database. Think of it as the organizational view of the entire database.
Option B: View - A view is a virtual table based on the results of a query. It doesn't change the actual database structure, just provides a different way to see the data.
Option C: Instance - An instance refers to a running copy of the MySQL server. It's not related to the database structure.
Option D: Table - A table is a collection of data organized into rows and columns. While tables are part of the database structure, the schema defines the overall organization of the database, including all the tables.
So, the answer is Option A: Schema. The schema represents the organizational views of the entire database in MySQL.
29. On UNIX, statements entered in 'MySQL' are saved in which file?
Answer & Solution
Think of it like a notepad for your SQL commands.
Whenever you type something into MySQL, it's like writing in this notepad.
The question asks what the name of this notepad file is.
Out of the options given, .mysql_history is the correct answer.
This file is where MySQL stores the commands you've executed.
You can access this history to easily re-run previous commands.
The other options are not used for this purpose.
30. Which is the correct format to store date in the SQL?
Answer & Solution
MySQL has a specific format for storing dates, and it's important to use the right format so your database can understand and work with the dates correctly.
Let's look at the options:
Option A: DEC-01-1991
This format uses abbreviations for the month ("DEC" for December), which is not the standard way MySQL expects dates.
Option B: 01-1991-11
This format is also incorrect because it puts the day before the year, which isn't the standard order.
Option C: 01-DEC-12
This option is similar to Option A, using an abbreviation for the month, and is therefore also incorrect.
Option D: 1991-11-01
This is the correct format for storing dates in MySQL. It follows the standard YYYY-MM-DD format, where:
- YYYY represents the year (e.g., 1991)
- MM represents the month (e.g., 11 for November)
- DD represents the day (e.g., 01 for the 1st)
Therefore, the answer is Option D: 1991-11-01.
Always remember to use the YYYY-MM-DD format when storing dates in MySQL to ensure consistency and avoid errors.
Read More Section(MySQL Miscellaneous)
Each Section contains maximum 100 MCQs question on MySQL Miscellaneous. To get more questions visit other sections.
- MySQL Miscellaneous - Section 1
- MySQL Miscellaneous - Section 2
- MySQL Miscellaneous - Section 3
- MySQL Miscellaneous - Section 5
- MySQL Miscellaneous - Section 6
- MySQL Miscellaneous - Section 7
- MySQL Miscellaneous - Section 8
- MySQL Miscellaneous - Section 9
- MySQL Miscellaneous - Section 10
- MySQL Miscellaneous - Section 11
- MySQL Miscellaneous - Section 12