Dump a specific table or few rows in MySQL Server

The 'mysqldump' command is used to dump databases managed by MySQL. Let's consider three the most useful cases of MySQL database dumping.

The simplest case is the whole database dumping:

mysqldump -u username -ppassword database_name  > the_whole_database_dump.sql

Sometimes, there's a need to dump a single table from your database. You can do it in the next way:

mysqldump -u username -ppassword database_name table_name > single_table_dump.sql

You can also specify several tables separated by whitespace to dump these tables only.

If you want to dump only rows that meet a specific criteria, you can add 'where' option to your mysqldump command. For example, dump only rows where date_created is today:

mysqldump -u username -ppassword database_name table_name --where="date_created='2013-06-25'" > few_rows_dump.sql


                                                                                             

                                                                                                                 Prepared by Ajeyudu Bandaru

Post patching

--Post Patching Steps

--step1: Verify installation from summary.txt file
--step2: Connect to the instance and verify the patch information
       select  serverproperty('productlevel')
       select @@VERSION
--step3: Restart the system
--step4: Check that all dbs has come online
       select  name,state_desc from sys.databases
--step5: Take backup of all system dbs.
       --master, model, msdb, resource
       backup database master to disk='master.bak'
--step6: Verify that all dbs are consistant
       dbcc checkdb(master)
--step7: Allow the appl team/Testing team to check connectivity from appls.
--step8: Make the instance available to the appls by enabling TCP/IP of the instance.
--step9: To check complete information
SELECT
SERVERPROPERTY('ProductLevel') AS ProductLevel,
SERVERPROPERTY('ProductUpdateLevel') AS ProductUpdateLevel,
SERVERPROPERTY('ProductBuildType') AS ProductBuildType,
SERVERPROPERTY('ProductUpdateReference') AS ProductUpdateReference,
SERVERPROPERTY('ProductVersion') AS ProductVersion,
SERVERPROPERTY('ProductMajorVersion') AS ProductMajorVersion,
SERVERPROPERTY('ProductMinorVersion') AS ProductMinorVersion,
SERVERPROPERTY('ProductBuild') AS ProductBuild
GO

How to Reverse Log Shipping Roles in SQL Server

There are times when you may need to reverse the roles of a primary and standby server.  This is common when you need to patch the primary server and still need to allow users access to the data.  When using database mirroring or SQL clustering as your SQL Server high availability option, reserving the roles of the primary and standby servers is quite easy.  With log shipping, however, it is not as straight forward.

You can always bring the standby database online, create a full backup of it, and restore onto the (previously) primary database to initialize it for log shipping.  However, this approach can be cumbersome especially if the database is large. The following steps will allow you to reverse log shipping roles without the need to initialize the (new standby) database.
  • Disable the log shipping backup job on the primary server.
  • On the standby server, run the log shipping copy and restore jobs to restore any remaining transaction log backups.
  • Disable the log shipping copy and restore jobs on the secondary server.
  • On the primary server, create on last transaction log backup using the NORECOVERY option.
  • On the standby server, restore this transaction log backup using the RECOVERY option.
  • On the standby server (which will now be the primary server), right click on the database and select Properties -> Transaction Log Shipping.  Enable the database to become the primary database and configure the backup and secondary server settings.