
Friday, September 25, 2009
Thursday, September 24, 2009
MYSQL: Bulk Insert
In mysql, we can quickly insert many rows into a table from one or many tables. This we can easily achive using the insert_select.
insert_select statment syntax
INSERT [LOW_PRIORITY HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [(col_name,...)] SELECT ... [ ON DUPLICATE KEY UPDATE col_name=expr, ... ]
Example:
INSERT INTO table1 (name, description) SELECT c.name,c.description FROM table2 c
insert_select statment syntax
INSERT [LOW_PRIORITY HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [(col_name,...)] SELECT ... [ ON DUPLICATE KEY UPDATE col_name=expr, ... ]
Example:
INSERT INTO table1 (name, description) SELECT c.name,c.description FROM table2 c
MYSQL Database Size
Hi,
Here is the steps to get the Database size details in mysql.
1) excute the following command
show table status like '%';
2) To get the total allocated space to a database
SUM(data_length) + SUM(index_length)
3) Total of actual data:
(SUM(data_length) - SUM(data_free)) + SUM(index_length)
4) Allocated but unused:
SUM(data_free)
Regards
DeepthiMahesh
Here is the steps to get the Database size details in mysql.
1) excute the following command
show table status like '%';
2) To get the total allocated space to a database
SUM(data_length) + SUM(index_length)
3) Total of actual data:
(SUM(data_length) - SUM(data_free)) + SUM(index_length)
4) Allocated but unused:
SUM(data_free)
Regards
DeepthiMahesh
Wednesday, September 23, 2009
MYSQL Triggers examples.
Trigger syntax
CREATE TRIGGER "trigger_name" "triggger_time"
"trigger_event" ON "table_name_onwhichtriggershouldfire"
FOR EACH ROW
BEGIN
""trigger_statements"
END;
Examples :
CREATE TRIGGER insert_test AFTER INSERT ON component
FOR EACH ROW
BEGIN
INSERT INTO TAG (name) VALUES (new.Name);
END;
Dropping Trigger
DROP TRIGGER [IF EXISTS] [schema_name.]trigger_name
example :
drop trigger [if exists] osmp.testTrigger
Show all the triggers
SHOW TRIGGERS
Show particular Trigger
show create trigger "trigger_name"
CREATE TRIGGER "trigger_name" "triggger_time"
"trigger_event" ON "table_name_onwhichtriggershouldfire"
FOR EACH ROW
BEGIN
""trigger_statements"
END;
Examples :
CREATE TRIGGER insert_test AFTER INSERT ON component
FOR EACH ROW
BEGIN
INSERT INTO TAG (name) VALUES (new.Name);
END;
Dropping Trigger
DROP TRIGGER [IF EXISTS] [schema_name.]trigger_name
example :
drop trigger [if exists] osmp.testTrigger
Show all the triggers
SHOW TRIGGERS
Show particular Trigger
show create trigger "trigger_name"
How to connect to a NetMeeting
Here are the steps to connect to Net meetings.
1) Go to start --> run --> type "conf" (on both PCs)
2) A window will be opened, type the IP address in the first text box, then click on the "Place call" button.
3) A dialog will open on the other side for acceptance.
4) After we get the acceptance, we can use as MOC (Microsoft Office communicator)
Wednesday, September 9, 2009
what is $() in Jquery?
Hi, jQuery uses "$" as a shortcut for "jQuery" which returns a special Java-Script object, this object contains an array of DOM elements that matches the selector.
So, $("#id") == jQuery("#id") also called Selector($).
Some JavaScript libraries uses $ too (example: prototype). To avoid conflict with those other libraries jQuery provides jQuery.noConflict() function. Calling this function the control of the $ variable goes back to the other library that first implemented it. Doing this to use jQuery you can't do this $('div.someClass') anymore, instead jQuery('div.someClass'). Alternatively can do this: jQuery.noConflict();jQuery.ready(function($) { // use $ for jQuery}//use $ for the other libraryWhen writing plugins to avoid problems with the usage of noConflict you can pass 'jQuery' to a function: function($) {//use $ writing your plugin}(jQuery)
So, $("#id") == jQuery("#id") also called Selector($).
Some JavaScript libraries uses $ too (example: prototype). To avoid conflict with those other libraries jQuery provides jQuery.noConflict() function. Calling this function the control of the $ variable goes back to the other library that first implemented it. Doing this to use jQuery you can't do this $('div.someClass') anymore, instead jQuery('div.someClass'). Alternatively can do this: jQuery.noConflict();jQuery.ready(function($) { // use $ for jQuery}//use $ for the other libraryWhen writing plugins to avoid problems with the usage of noConflict you can pass 'jQuery' to a function: function($) {//use $ writing your plugin}(jQuery)
How to get the URL parts using Javascript
Hi,
Here is the code to get the URL parts using Javascript.
1) How to get the path name
var pathname= window.location.pathname;
alert( " Pathname "+ pathname );
2) How to get the hostname
var hostname = window.location.host;
alert( hostname);
3) How to get the complete URL
var URL = window.location;
alert("URL "+URL);
4) How to get the URL with out parameters
var URLWithOutPrameters = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname;
alert(URLWithOutPrameters );
5) How to get the Protocal in the URL.
var protocal = window.location.protocol;
alert( " protocal "+ protocal);
5) How to get the parameters in the URL
var name = "tagName"; // We can place any name , the name should contain in the URL.
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results != null )
alert( results[1]); // will display the value of the name (key value pair) ,
}
Here is the code to get the URL parts using Javascript.
1) How to get the path name
var pathname= window.location.pathname;
alert( " Pathname "+ pathname );
2) How to get the hostname
var hostname = window.location.host;
alert( hostname);
3) How to get the complete URL
var URL = window.location;
alert("URL "+URL);
4) How to get the URL with out parameters
var URLWithOutPrameters = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname;
alert(URLWithOutPrameters );
5) How to get the Protocal in the URL.
var protocal = window.location.protocol;
alert( " protocal "+ protocal);
5) How to get the parameters in the URL
var name = "tagName"; // We can place any name , the name should contain in the URL.
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results != null )
alert( results[1]); // will display the value of the name (key value pair) ,
}
Thursday, September 3, 2009
MYSQL Vs Oracle
Hi,
Here I found some differances in MySQL vs Oracle
1) dual table ( in oracle we need to specify the dual table , but in MYSQL , we need not..)
2) MySQL only supports primitive data types, DATE, NUMBER and STRING and TIME.
3) MySQL supports more types of tables than Oracle, including MyISAM, MERGE, ISAM, innoDB, BDB and HEAP
4) In oracle we use "" for Concatenate strings, but in mysql , we have a function called "CONCAT("String1", "String2") "
Here I found some differances in MySQL vs Oracle
1) dual table ( in oracle we need to specify the dual table , but in MYSQL , we need not..)
2) MySQL only supports primitive data types, DATE, NUMBER and STRING and TIME.
3) MySQL supports more types of tables than Oracle, including MyISAM, MERGE, ISAM, innoDB, BDB and HEAP
4) In oracle we use "" for Concatenate strings, but in mysql , we have a function called "CONCAT("String1", "String2") "
Wednesday, September 2, 2009
MYSQL Procedures
Hi,
Here is the sample of the creating the procedures & excuting the procedures.
Creating Procedure:
CREATE PROCEDURE appl_osmp.createTest(IN testName VARCHAR(20), IN ComponentIDs TEXT )
BEGIN
DECLARE TagID INT DEFAULT 1;
INSERT INTO TEST (name) VALUES (testName);
END
Droping procedure :
drop procedure createTest;
Call the procedure:
call createTest("tom5","16395,16722,17175,16999");
Here is the sample of the creating the procedures & excuting the procedures.
Creating Procedure:
CREATE PROCEDURE appl_osmp.createTest(IN testName VARCHAR(20), IN ComponentIDs TEXT )
BEGIN
DECLARE TagID INT DEFAULT 1;
INSERT INTO TEST (name) VALUES (testName);
END
Droping procedure :
drop procedure createTest;
Call the procedure:
call createTest("tom5","16395,16722,17175,16999");
MYSQL
Hi,
Here is MYSQL Query to find
1) Number of occurance of a substring in a string.
SELECT length(" '123' ,'234','345' ")-length(REPLACE(" '123' ,'234','345' ")-, ',' , '' )) into no_of_commas;
Out put : 2
2) Equilvalent to dbms_output.put_line in MYSQL is
select "some smaple text" ;
3) To view the SP in the console.
SHOW CREATE PROCEDURE
Here is MYSQL Query to find
1) Number of occurance of a substring in a string.
SELECT length(" '123' ,'234','345' ")-length(REPLACE(" '123' ,'234','345' ")-, ',' , '' )) into no_of_commas;
Out put : 2
2) Equilvalent to dbms_output.put_line in MYSQL is
select "some smaple text" ;
3) To view the SP in the console.
SHOW CREATE PROCEDURE
Subscribe to:
Comments (Atom)