Select Category 
 

MS SQL Interview Questions Answers

MS SQL Interview Question - 1 : -

Can you save your connection settings to a conf file?

MS SQL Interview Answer - 1 : -

Yes, and name it ~/.my.conf. You might want to change the permissions on the file to 600, so that it’s not readable by others.
 

MS SQL Interview Question - 2 : -

What are the different table present in MYsql?

MS SQL Interview Answer - 2 : -

MyISAM: This is default. Based on Indexed Sequntial Access Method. The above SQL will create a MyISA table.
ISAM : same
HEAP : Fast data access, but will loose data if there is a crash. Cannot have BLOB, TEXT & AUTO INCRIMENT fields
BDB : Supports Transactions using COMMIT & ROLLBACK. Slower that others.
InoDB : same as BDB
 

MS SQL Interview Question - 3 : -

how to Install a MySQL Binary Distribution?

MS SQL Interview Answer - 3 : -

You need the following tools to install a MySQL binary distribution:
GNU gunzip to uncompress the distribution.
A reasonable tar to unpack the distribution. GNU tar is known to work. Sun tar is known to have problems.
An alternative installation method under Linux is to use RPM (RedHat Package Manager) distributions.

If you run into problems, PLEASE ALWAYS USE mysqlbug when posting questions to mysql@lists.mysql.com. Even if the problem isn't a bug, mysqlbug gathers system information that will help others solve your problem. By not using mysqlbug, you lessen the likelihood of getting a solution to your problem! You will find mysqlbug in the `bin' directory after you unpack the distribution.

The basic commands you must execute to install and use a MySQL binary distribution are:

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
shell> ln -s mysql-VERSION-OS mysql
shell> cd mysql
shell> scripts/mysql_install_db
shell> chown -R mysql /usr/local/mysql
shell> chgrp -R mysql /usr/local/mysql
shell> bin/safe_mysqld --user=mysql &


You can add new users using the bin/mysql_setpermission script if you install the DBI and Msql-Mysql-modules Perl modules.
A more detailed description follows.

Pick the directory under which you want to unpack the distribution, and move into it. In the example below, we unpack the distribution under `/usr/local' and create a directory `/usr/local/mysql' into which MySQL is installed. (The following instructions therefore assume you have permission to create files in `/usr/local'. If that directory is protected, you will need to perform the installation as root.)

 

MS SQL Interview Question - 4 : -

Explain advantages of MyISAM over InnoDB?

MS SQL Interview Answer - 4 : -

Much more conservative approach to disk space management - each MyISAM table is stored in a separate file, which could be compressed then with myisamchk if needed. With InnoDB the tables are stored in tablespace, and not much further optimization is possible. All data except for TEXT and BLOB can occupy 8,000 bytes at most. No full text indexing is available for InnoDB. TRhe COUNT(*)s execute slower than in MyISAM due to tablespace complexity.
 

MS SQL Interview Question - 5 : -

How do you get a portion of a string?

MS SQL Interview Answer - 5 : -

SELECT SUBSTR(title, 1, 10) from techpreparation_questions;
 

MS SQL Interview Question - 6 : -

If you run this, what does it return?
select applock_mode('public', 'SalesApp', 'Transaction')

MS SQL Interview Answer - 6 : -

The type of lock being held by an application that requested it.
This command returns the lock mode held by an application that was requested with the sp_getapplock procedure.

insert mytable select ''
insert mytable select ' '
select * from mytable where mychar = ''
select * from mytable where mychar = ' '

 

MS SQL Interview Question - 7 : -

How would you delete a column?

MS SQL Interview Answer - 7 : -

ALTER TABLE techpreparation_answers DROP answer_user_id.
 

MS SQL Interview Question - 8 : -

When Privilege Changes Take Effect?

MS SQL Interview Answer - 8 : -

When mysqld starts, all grant table contents are read into memory and become effective at that point.
Modifications to the grant tables that you perform using GRANT, REVOKE, or SET PASSWORD are noticed by the server immediately.

If you modify the grant tables manually (using INSERT, UPDATE, etc.), you should execute a FLUSH PRIVILEGES statement or run mysqladmin flush-privileges or mysqladmin reload to tell the server to reload the grant tables. Otherwise your changes will have no effect until you restart the server. If you change the grant tables manually but forget to reload the privileges, you will be wondering why your changes don't seem to make any difference!

When the server notices that the grant tables have been changed, existing client connections are affected as follows:

Table and column privilege changes take effect with the client's next request.
Database privilege changes take effect at the next USE db_name command.
Global privilege changes and password changes take effect the next time the client connects.

 

MS SQL Interview Question - 9 : -

How does a differential backup know which extents have changed so that it can be very quickly run?

MS SQL Interview Answer - 9 : -

The DCM tracks changes. The differential backup reads the extents from this structure.
A differential backup uses the Differential Change Map to determine which extents have changed and need to be include in the backup. This greatly speeds the differential backup process.
 

MS SQL Interview Question - 10 : -

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?

MS SQL Interview Answer - 10 : -

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
 

MS SQL Interview Question - 11 : -

But what if you really want to store the timestamp data, such as the publication date of the article?

MS SQL Interview Answer - 11 : -

Create two columns of type TIMESTAMP and use the second one for your real data.
 

MS SQL Interview Question - 12 : -

How do I upgrade on a hot replication setup?

MS SQL Interview Answer - 12 : -

If you are upgrading pre-3.23.26 versions, you should just lock the master tables, let the slave catch up, then run FLUSH MASTER on the master, and FLUSH SLAVE on the slave to reset the logs, then restart new versions of the master and the slave. Note that the slave can stay down for some time - since the master is logging all the updates, the slave will be able to catch up once it is up and can connect.
After 3.23.26, we have locked the replication protocol for modifications, so you can upgrade masters and slave on the fly to a newer 3.23 version and you can have different versions of MySQL running on the slave and the master, as long as they are both newer than 3.23.26.
 

MS SQL Interview Question - 13 : -

How MySQL Uses Memory ?

MS SQL Interview Answer - 13 : -

The list below indicates some of the ways that the mysqld server uses memory. Where applicable, the name of the server variable relevant to the memory use is given:

The key buffer (variable key_buffer_size) is shared by all threads; Other buffers used by the server are allocated as needed.

Each connection uses some thread-specific space: A stack (default 64K, variable thread_stack), a connection buffer (variable net_buffer_length), and a result buffer (variable net_buffer_length). The connection buffer and result buffer are dynamically enlarged up to max_allowed_packet when needed. When a query is running, a copy of the current query string is also allocated.
All threads share the same base memory.
Only the compressed ISAM / MyISAM tables are memory mapped. This is because the 32-bit memory space of 4GB is not large enough for most big tables. When systems with a 64-bit address space become more common we may add general support for memory mapping.
Each request doing a sequential scan over a table allocates a read buffer (variable record_buffer).
All joins are done in one pass, and most joins can be done without even using a temporary table. Most temporary tables are memory-based (HEAP) tables. Temporary tables with a big record length (calculated as the sum of all column lengths) or that contain BLOB columns are stored on disk. One problem in MySQL versions before Version 3.23.2 is that if a HEAP table exceeds the size of tmp_table_size, you get the error The table tbl_name is full. In newer versions this is handled by automatically changing the in-memory (HEAP) table to a disk-based (MyISAM) table as necessary. To work around this problem, you can increase the temporary table size by setting the tmp_table_size option to mysqld, or by setting the SQL option SQL_BIG_TABLES in the client program.

In MySQL Version 3.20, the maximum size of the temporary table was record_buffer*16, so if you are using this version, you have to increase the value of record_buffer. You can also start mysqld with the --big-tables option to always store temporary tables on disk. However, this will affect the speed of many complicated queries.
Most requests doing a sort allocates a sort buffer and 0-2 temporary files depending on the result set size.

Almost all parsing and calculating is

 

MS SQL Interview Question - 14 : -

Error severity 13 indicates what?

MS SQL Interview Answer - 14 : -

Transactional deadlock errors.
This level of error severity indicates a transaction deadlock error.
 

MS SQL Interview Question - 15 : -

What is a correlated sub-query? How can these queries be useful?

MS SQL Interview Answer - 15 : -

The more seasoned developer will be able to accurately describe this type of query. A correlated sub-query is a special type of query containing a sub-query. The sub-query contained in the query actually requests values from the outside query, creating a situation similar to a loop. You can find a more detailed description as to how these special types of queries work in this article.