Posts

Showing posts with the label My Sql

How to add Primary Key and Auto Increment on different fields of MySql

 Normal code generated by MySql:- CREATE TABLE `categorymaster` (   ` CategoryID ` int(11) NOT NULL AUTO_INCREMENT,   ` Category ` varchar(200) DEFAULT NULL,   `IsActiv` int(11) DEFAULT NULL,   `ImagePath` varchar(200) DEFAULT NULL,   `DisplayOrder` int(11) DEFAULT NULL,   PRIMARY KEY (` Category `) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; In the above data stucture I want to make the " Category " as Primary Key and " CategoryId " as Auto Increment. But Table Wizard always give errors so, I decided to write my own Statement. Following is the statement which will create perfect structure according to my requirement. DROP TABLE `dbname`.`categorymaster`; CREATE TABLE `categorymaster` (   `CategoryId` int(11) unsigned NOT NULL AUTO_INCREMENT,   `Category` varchar(200) DEFAULT NULL,   `IsActiv` int(11) DEFAULT NULL,   `ImagePath` varchar(200) DEFAULT NULL,   `DisplayOrder` in...

SQL Function Reference:Oracle vs.SQL Server vs. My SQL Part- III

Date Functions Function - Date addition Oracle - (use +) SQL Server - DATEADD My Sql - Need To Update Function - Date subtraction Oracle - (use -) SQL Server - DATEDIFF My Sql - Need To Update Function - Last day of month Oracle - LAST_DAY SQL Server - N/A My Sql - Need To Update Function -Time zone conversion Oracle - NEW_TIME SQL Server - N/A My Sql - Need To Update Function -First weekday after date Oracle - NEXT_DAY SQL Server - N/A My Sql - Need To Update Function -Convert date to string Oracle -TO_CHAR SQL Server - DATENAME My Sql - Need To Update Function -Convert date to number Oracle -TO_NUMBER(TO_CHAR()) ...

SQL Function Reference:Oracle vs.SQL Server vs. My SQL Part- II

String Functions Function - Convert character to ASCII Oracle - ASCII SQL Server - ASCII My Sql - ASCII Function -String concatenate Oracle - CONCAT SQL Server - (expression + expression) My Sql - CONCAT Function -Convert ASCII to character Oracle - CHR SQL Server - CHAR My Sql - CONCAT Function -Return starting point of character in character string (from left) Oracle - INSTR SQL Server - CHARINDEX My Sql - INSTR Function -Convert characters to lowercase Oracle - LOWER SQL Server - LOWER My Sql - LOWER Function -Convert characters to uppercase Oracle - UPPER SQL Server - UPPER My Sql - UPPER Function -Pad left side of character string Oracle - LPAD SQL Server - N/A My Sql - LPAD Function -Remove leading blank spaces Oracle - LTRIM SQL Server - LTRIM My Sql - LTRIM Function -Remove trailing bl...

SQL Function Reference:Oracle vs.SQL Server vs. My SQL Part- I

Generally the major issue we face while development is the availability of common functions in different database(s). I am facing this issue from last so many years. Then I had start preparing a table for common functions of different database(s). The commonly used databases are Oracle, Sql Server and My Sql. Their is so many other database(s) are also available but commonly I works on these database(s) only. Following is the common list of functions in different database(s):- Math Functions Function - Absolute value Oracle - ABS SQL Server - ABS My Sql - ABS Function - Arc cosine Oracle - ACOS SQL Server - ACOS My Sql - ACOS Function - Arc sine Oracle - ASIN SQL Server - ASIN My Sql - ASIN Function - Arc tangent of n Oracle - ATAN SQL Server - ATAN My Sql - ATAN Function - Arc tangent of n and m Oracle - ATAN2 SQL Server - ATAN2 My Sql - Please Suggest Function - Smallest integer >= value Orac...

How to get tables names in MySql (sysobjects in sql server)

In Sql server we have a table sysobjects which holds names of all the tables i.e. system and user tables. Like the same we have command “Show tables” which show all the tables of specified database. Syntax Show Tables from <databasename> Here is an example. SHOW TABLES FROM MySql If you had already select a database you can only use Show tables to show all the tables in the database. For ex. Select database MySql and in Sql command window enter following text SHOW TABLES And click on Run. It will show all the tables which is avalible in the list

How to take back up of my sql database using C#

Image
You can also download running code. Taking a back up of my sql using C# is very easy but this also be termed as tricky backup. Like Sql server my sql does not provide built in stored procedures to take back up. For back up my sql use a Exe file named “mysqldump.exe” You will find this Exe file in “C:\Program Files\MySQL\MySQL Server 5.0\bin” folder of mySql. This file takes so many parameters for different options. But my task is to simply take a backup of single database To take a backup of single database following are the parameters mysqldump -u<usernane> -p <password> -h<servername or ip> <databasename> > <localtion to take backup> Please let me know if this helps you to perform your task easily.