Question:- How Can You Retrieve A Portion Of Any Column Value By Using A Select Query?
Answer:- SUBSTR() function is used to retrieve the portion of any column.
Question:- How Can You Rename And Remove Any Column Of A Table?
Answer:- To rename column: ALTER TABLE table_name CHANGE COLUMN old_column_name new_column_name column_defination.
Question:- What Is An Index?How Can An Index Be Declared In MySQL?
Answer:- An index is a data structure of a MySQL table that is used to speed up the queries. It is used by the database search engine to find out the records faster. One or more fields of a table can be used as an index key. Index key can be assigned at the time of table declaration or can be assigned after creating the table. • Create INDEX: CREATE INDEX [index name] ON [table name]([column name]); • List all indexes: SHOW INDEXES FROM[table name];
Question:- How Many Columns Can Be Used For Creating An Index?
Answer:- A maximum of 16 indexed columns can be created for any standard table.
Question:- What Is The View? How Can You Create And Drop Views In MySQL?
Answer:- A view works as a virtual table that is used to store the query and returns a result set when it is called. An updatable view is also supported by MySQL. CREATE VIEW view_name AS SELECT column1, column2 FROM table_name WHERE condition;
Question:- Explain The Different Types Of MySQL Joins.
Answer:- • Inner join: It is a default join. It returns records when the values match in joining tables. • Left outer join: It returns all the records from the left table based on the matched records from the right table. • Right outer join: It returns all the records from the right table based on matched records from the left table. • Full outer join: It returns all the records that match from the left or right table.
Question:- How Can You Retrieve A Particular Number Of Records From A Table?
Answer:- A LIMIT clause is used with the SQL statement to retrieve a particular number of records from a table. From which record and how many records will be retrieved are defined by the LIMIT clause.
Question:- How Can You Count The Total Number Of Records Of Any Table?
Answer:- COUNT() function is used to count the total number of records of any table.
Question:- What Is A Storage Engine? What Are The Differences Between InnoDB And MyISAM Engines?
Answer:- One of the major components of MySQL server is the storage engine for doing different types of database operations. Each database table created is based on the specific storage engine MySQL supports two types of storage engine i.e. transactional and non-transactional. InnoDB is the default storage engine of MySQL which is a transactional storage engine. MyISAM storage engine is a non-transactional storage engine.
Question:- How Can You Display The Maximum Salary In SQL?
Answer:- To display the maximum salary in SQL, you can use the inbuilt function called MAX().
Question:- How To Display Nth Highest Salary From A Table In A MySQL Query?
Answer:- Query: SELECT DISTINCT(salary)FROM employee ORDER BY salary DESC LIMIT n-1,1 So if you want to find out the 2nd highest salary, consider the below query. SELECT DISTINCT(salary) FROM employee ORDER BY salary DESC LIMIT 1,1
Question:- What Is SQL Query To Find The Maximum Salary Of Each Department?
Answer:- SELECT dept_id, MAX(salary) FROM employee GROUP BY dept_id;
Question:- How Do You Find All Employees With Their Managers?(Consider There Is A Manager Id Also In Employee Table)
Answer:- SELECT m.emp_name as Employee, e.emp_name as Manager FROM employee e, employee m WHERE m.manager_id =e.id;
Question:- How To Find The Count Of Duplicate Rows?
Answer:- SELECT id, COUNT(id) from employee Group by id Having COUNT(id)>1 Order by COUNT (id) desc;
