Skip to main content

Posts

SQL Select Query Examples-retrieve Last five records,subquery , last letters in capital

Select Query to retrieve Last five records of the table select * from emp a where 5 >= (select count(1) from emp b where a.empno != b.empno and a.sal <= b.sal) order by a.sal desc assumptions: 1. Empno is primary key in emp table 2. 5 last records must be required based on some sorting, so i took it as salary . Select Query to get the first and last letters in capital in SQL This is sample example to use Select Query to get the first and last letters in capital in SQL. You can use with your table instead of test5. upper is function to get letter in upper case and substr method is used to get first and last letter. select upper(substr(ename,1,1)) || substr(ename,2,length(ename)-2) || upper(substr(ename,length (ename),1)) from test5; Example of subquery in sql select e.employee_id,e.first_name||' '||last_name as name,e.department_id,e.hire_date,e.manager_id,d.department_name, m.first_name||' '||m.last_name manager from employees e join department

Tips for Linux Kernel scheduling,shutdown and restart command,steps to kernel updating

 kernel scheduling in Linux In kernel you have kernel threads. Some part of the kernel code runs in the userspace process context and some other part runs in the kernel thread context. All the userspace processes and kernel threads are scheduled with no difference except that their priority(that is both userspace process and kernel threads are treated same). we can change the kernel with our algorithm.. algorithm in sence round robin,shortest job first, fcfs, etc. You have a mirror or some part (dono the exact name) in kernel where you store your algorithm. and make kernel work in your algorithm. If your algorithm works fine without crashing the system you can set ur algorithm as default overwriting the existing one. Its possible to write your own algorithm too. scheduler schedules processes either it may be user or kernel, all user and kernel processes are same and kernel treats them in the same manor,except kernel process will not be swapped out, kernel process will have mor

Redirect output in a file,Check Exist validation,Cursor Example in PL SQL

Redirect output in a file in Oracle PL SQL There are different ways: a) Before you execute the package you can enable SPOOL. or b) Create a temporary package and insert the log messages into that so that data can be viewed later on the temporary table. or c) Use DBMS_FILE package procedure to open and write data into files. Check exists validation using pl/sql declare v_deptno dept.deptno%type:=&gdeptno; cursor deptcursor is select * from dept where deptno=v_deptno; v_deptcursor deptcursor%rowtype; begin open deptcursor; fetch deptcursor into v_deptcursor; if deptcursor%found then dbms_output.put_line('v_deptcursor.ename); else dbms_output.put_line('sorr..! no deptloyee exists..'); end if; end; PL Sql program example of cursor on employee table This is a PL Sql program example of cursor on employee table to check whether employee exist or not. declare v_empno emp.empno%type:=&gempno; cursor em

How To Upgrade Your Computer's Memory,Renaming of Drives

 Upgrade Your Computer's Memory Upgrading computer memory involves increasing the RAM of your computer, so the first thing you have to figure out is the type of RAM the system uses, how it's configured, and how many RAM slots you have available. A memory upgrade usually requires that you first check the computer's user manual, or the manual for the motherboard. Find out if the memory is parity or non-parity. You can also check the website of your computer to find out the memory you need for computer memory upgrades. Now, find out what the speed of the PC memory is. When dealing with computer memory, you have to know this information. Next, does your computer use single in-line memory modules (SIMMs) or dual in-line memory modules (DIMMs)? When conducting an upgrade, it's also key to figure out if the computer uses regular, FPM, EDO, or Synch DRAM. How many pins are on the motherboard? 30, 72, or 168? Computer memory upgrades require that you remove the cover from

Set batch file which schedules dump from database in MYSQL

Set batch file which schedules dump from database in MYSQL To Set batch file which schedules dump from database in MYSQL you can try following way. echo Running dump... c:\MYSQL\bin\mysqldump -u root -padmin --result-file="c:\back\backup_ %date%.sql" db_dm echo Done! Placing MySQL database from local computer to host You Can place MySQL database from local computer to host by following steps. Import/export file first export the database click on export tab you'll get the query for whole database copy it and paste in notepad save it with .sql extension then open your server control panel go to phpmyadmin and import the saved sql file

PHP Tips-Getting the nodes list of xml doument with responseXml in ajax ,call image save in database,time difference etc

Getting the nodes list of xml doument with responseXml in ajax var obj = ""; function callAjaxObj() { try { obj = new XMLHttpRequest(); } catch(e) { try { obj = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { obj = ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("your browser doesn't support ajax"); return false; } } } } function testResponseXml() { callAjaxObj(); obj.open("get","sample.xml",true); obj.onreadystatechange=function() { if(obj.readyState==4) { var doc = obj.responseXML.documentElement; //var doc = obj.responseXML; alert(doc.getElementsByTagName('user').length); } } obj.send(null); } Example of calender script in PHP calender script in PHP echo " $title $year "; echo "SMTWTFS"; $day_count = 1; echo ""; while (

Query to show all tables names, see all the objects,create the table into the trigger in sql

Query to show all table names select table_name from dba_tables SELECT *FROM TAB; Query to see all the objects in sql This is a very simple query to get all the objects in sql. User_Objects is sql system table which include all object information as a records. select * from USER_OBJECTS; This is small query but it could be very helpful for you. Create the table into the trigger using pl sql To create table into the trigger using pl/sql you can try following code in SQL query editor or in stored procedure. Create or replace trigger b_br after delete on EMP declare n integer; PRAGMA AUTONOMOUS_TRANSACTION; begin dbms_output.put_line('Table Creation in process..'); execute immediate 'create table b_t(b varchar2(10))'; dbms_output.put_line('Table Created..'); end; Delete from EMP; Same way you can add more columns in tables with different data types.

How to Improve Traffic To a blog,Make Your Blog Popular,Blogging platforms

Tips to Improve blog's Traffic  I t is not so easy to get traffic to each and every blog but I have experienced if you update your blog everyday then it will come on the first page of search engine (by the way always this does not work) yo can do one more thing try to use some new search word so that it will be easily accessible for search engine to get your blog just go to google and search some new word if you do not find similar blogs with that word that word is the best suit for your blog to get traffic 1. Make a habit of posting regularly in the blog. 2.Choose a proper template for your Blog. You don't expect people to like it if you have a cooking theme in a Technology blog. 3.Write a topic and post it in different sections and thereby create a series. This increases the curiosity of the web visitors who turn to the blog for the interesting follow-ups. 4.Optimize your blog to make it load Faster so that new visitor don't get annoyed to sit idle while your

DotNet ,C Sharp and SQL Interview Questions

DotNet and SQL Interview Questions 1)Say in a structure which is value type. we have added a reference type variable. will it be stored in stack memory or heap  2)in data-grid you are displaying a table. if you want to know what are the rows which are updated how do you implement it  3)suppose you want to store you connection string where are you going to store it apart from web.config and appsettings.  4)in try catch scenario there are two catch blocks one is System defined & other is user defined which will be executed first.  5)in boxing & unboxing which one is expensive.  6)difference between catch and throw  7)you have deployed windows service at client place. say suppose it is giving erroneous results. it is running application. how do you debug it.  8)there is a webservice deployed at the client place how can you check whether that application is working fine or not.  9)you have deleted a record from database from your application a at the same time so

Blogging Tips-Rules and regulation,Definition of adsense,improve traffic,Earn Money

Definition of adsense Adsense is a adv management team of google. They collects ads and puts in different websites. If we have websites, blogs etc. they provides ads. They shares their revenue with us by putting ads in our web pages. Google AdSense is a free program that empowers online publishers to earn revenue by displaying relevant ads on websites and blog.  It's a product of Google Inc.you need a approved adsense account then you will be able to publish ad and thus you can earn. Blogging Tips-Rules and regulation Few rules for before applying AdSense 1. your blog must be in active for 6 months 2. have at least 15 posts 3. submit your blog to major search engines like Google, Yahoo etc Where to place the ad's? It is natural for eye to wander in the right side, Have a rectangle ad in right side use blended ad's {blended = that color matches your blog} Add your ad's in end of posts Points which people do not like to see in your blog #1 Having bac

Song- Khamoshiyan Piano keyboard Chord,Notation and songs Lyrics

Tips for SQL Server Database Engine Tuning Advisor 2012

I want to share some tips through image sharing in  SQL Server Database Engine Tuning Advisor 2012.Database Engine Tuning Advisor  is used to recommend indexes and other actions which is required to improve performance of your database.  If there is a big size data then you should use index technique to improve database performance.

What is difference between the index by table and nested tables

Following are the  difference between the index by table and nested tables. Index by table - 1)Not store in database  2)Automatically initialize when declared . 3)Index By Table is something like a hash-map or map in another languages where you can index a value with either String or Integer. Nested table  1)Store in database  2)Initialize using contractor . 3)Where are Nested Table is something like Array in another languages but the difference is it is not fixed in size

Disadvantage of Bulk Collect in oracle

Bulk collect fetch all rows from table in single shot so if table have so many rows then it can cause consume too much session memory and can raise an error .for this developer should set limit parameter carefully by keeping performance or memory overhead in mind. Suppose I have 10000 rows in my emp table but my session doesn't have enough memory to hold 10000 row on that case we can use limit parameter. declare c_limit PLS_INTEGER=100; cursor emp_cur is select empno from emp where deptno=&depnto; type l_emp_id_t is table of emp.empno%type; l_emp_ids l_emp_id_t ; begin open emp_cur; loop fetch emp_cur bulk collect into l_emp_ids limit c_limit; exit when l_emp_ids.COUNT=0; end loop; end;

What is Ref cursor in SQL?

 Ref cursor is called dynamic cursor and it is a datatype and it is used to you can open the multiple select statement at run time and it is dynamic change the query Ref cursor is used to write more then one select statement in cursor. Ref cursor is 'pointer' datatype that allow you to quickly reference cursor result , using ref cursor we use the re-usability of cursor ,ref cursor is variable defined as a cursor type , which will point to, or reference a cursor result , ref cursor can be assigned to other ref cursor variable  Ref cursor is one data type and can be defined into one variable,this variable can be called as ref_cursor variable. We can use this variable for different SQL statements at run time. For more details you can visit this site mentioned in image

The Top Ten Software Companies in India

Names TCS LIMITED WIPRO LIMITED INFOSYS TECHNOLOGIES LIMITED SATYAM COMPUTER SERVICES LIMITED I-FLEX SOLUTIONS LIMITED TATA INFOTECH LIMITED CMC LIMITED MPHASIS BFL LIMITED MASTEK LIMITED MASTEK LIMITED NIIT LIMITED

Career and opportunity in NGO'S

Working in NGO needs different sets of knowledge, attitude and skills. And obviously it offers a good salary also. But the initial days are very crucial as every moment a development worker has to deal with people. In India different courses offered by various institutions offers an opportunity to enter into development sector (NGO sector is known as development sector for the professionals). The reputed institutes includes, TISS, Tata –Dhan Academy, XISS,KIIIT and IRMA. Etc. these institutes offers different courses in different names. Like MSW, Development Studies, Development Management, Rural Management etc. The job opportunity is very good. Initially one can earn between Rs.15000-20000. In abroad one can earn more but in most of the cases it need at least three years of experience. lease visit website of the few reputed NGOs. You could visit devnetjobs.com where you will find many opportunities. There are many NGOs working in Bangalore. Please explore with them. In ma

Difference in CHAR and VARCHAR2 Data type in SQL

Char is fixed length Datatype. and Varchar is variable length datatype. Suppose you have 2 columns, 1 with Char(40) another with Varchar2(40)  and both columns has values with only 10 characters in a record that time SQL server still occupy 40 character space in system for 1st column and 10 character space in system for 2nd column. Simple pick char if length is going to remain same otherwise pick varchar as a speed both have its advantage . Choosing data type cannot be done by yes or no you have to choose data type as per your requirement both are good and bad. 

Suggestions to get rid of from recovery mode of SQL database

These are just some Suggestions to get rid of from recovery mode of SQL database. Mostly suspension of database made due to any long process and long suspended query which generating deadlock and infinite loop for your database. Try these option. A. Alter database dbname set emergency Alter database dbname set single_user dbcc checkdb(‘dbname’,repair_allow_Data_loss) alter database dbname set multi_user B. we have to run dbcc checkdb only in the third step,because User does not want to loose the data. If that don't works, then we have to use allow data loss. but first option is better to restore with available backup, if back up is not there then we have to use this method. C.First find which file is corrupted, if Data file corruption immediately take Tail log backup then restore full backup followed by differential , log backups with no recovery finally restore tail log backup with recovery. D. 1. Ensure that the device file is actually available. 2. Use the supplemental stored

Finding Reasons for Slow SQL Server database performance

If you found your SQL Database performance is very slow then you can check below points. 1.Check if any blocking. 2- Check execution plan for any costly operator. 3- We can run DTA and take help from that but keep in mind it's not necessary to implement all suggestions provided by DTA. 4. Index fragmentation . 5. Missing indexes. 6. Stale update stats 7. Blocking & Deadlocks of queries. 8. Excessive compilation & recompilation. 9.Check long queries using trace of suspended records on high working time of transactions. 10.Check RAM utilization at SQL Server.