Thursday, August 6, 2009

LINUX commands

1.. ls
2.. cat
3.. Date
4.. echo
5.. pwd
6.. cp
7.. mkdir
8.. mv
9.. rm
10.. rmdir
11.. head
12.. wc
13.. whoami
14.. who
15.. vi
16.. uname
17.. umount
18.. tty
19.. tar
20..tee
21..tail
22.. rpm
23.. sh
24.. sort
25.. more
26.. find
27.. clear
28.. cal
29.. chmod
30.. merge
31.. sudo
32.. talk
33.. touch
34.. write
35.. last
36.. od
37.. gcc
38.. g++
39.. cut
40.. cmp
41.. cc
42.. banner
43.. bc
44.. join

Wednesday, April 15, 2009

LAB TEST OOPS

1. WAP that a class student stores roll no, class test stores marks the 2 subjects and result contains total marks obtained in the test class result inherit details marks from test and roll no through multilevel inheritance.
2. Concatenate 2 strings by overloading + operator
3. WAP to add 2 complex numbers by returning objects
4. WAP to swap private data of 2 classes.
5. Create a base class called shape .Use this class to store two double type values that could be used to compute the area of figures. Derive two specific classes’ triangle & rectangle from the base class shape. Add to the base class a member function get_data () to initialize base class data members and another member function display_area () to compute and display the area of the figure. Make display_area () as a virtual function & redefine this function in the derived class to suit their requirements.
6. To read a value of distance from one object and add with a value in another object using friend function.
7. WAP to implement addition operations on complex numbers using constructor overloading
8. String concatenation using dynamic memory allocation concept.

9. To compute the area of triangle and rectangle using inheritance and virtual function.
10. Design a class from which only one object can be created. If more than one object is created, then the program should terminate.

Friday, March 13, 2009

OOPS ASSIGNMENT - 9

Inheritance

1. Write a program which should have two classes A and B,A contain two data members and 3 methods and B class is inherited by class A, Class B contains one data member and two methods. Now multiply the two values of class A by using the object of class B and display the result.

2. Write a program which having 3 classes student, test and result, student class having method to accept enrollment number, test class accept student marks in 3 subjects which is inherited by class student and result class having methods to find sum of marks and displays, which is inherited by class test. Now by using the object of result class call the methods from other classes.


3. Create a class Basic_info having data members Player ID, Name, Age. Derive a class Add_info from Basic_info having data members player_type, height & weight. Include suitable member functions to input and display the data?


4. A bank maintains two types of accounts
Saving: includes
Compound interest
Withdrawal
Current
Minimum balance required

Create a class “account” that stores customer name, account number and type of account. From account derive cur_acc and sav_acc. Include necessary data members and member function to perform following tasks.

i. Accept deposit and update balance
ii. Display the balance
iii. Compute and deposit interest
iv. Check for minimum balance


5. Create a class student which includes name and roll number of the student. Derive classes test and sport out of class student which include test marks and sport marks respectively.

Derive a class result out of test and sport where total marks are calculates and displayed

Test the class result.

Friday, February 27, 2009

OOPS ASSIGNMENT - 8

Recursive Member Function

1.Write a program to find the factorial of a number using recursive member function.

2.write a program to find the sum of the digits of a number using recursive member function.

3.write a program to find the sum of n numbers using recursive member function.

4.write a program to find the gcd of two numbers using recursive member function.

Recursive constructor
1.write a program to find the factorial of a number using recursive constructor.

2.write a program to find the sum of n numbers using recursive constructor.

3.write a program to find the sum of the digits using recursive constructor.

4.write a program to find the gcd of two numbers using recursive constructor.

OOPS ASSIGNMENT - 7

Constructors and Destructors
1.write a program using constructor to find the area of a rectangle. This includes two data members(length and width), two member functions one is to display the length and width, other is to calculate the area and display that area.

2.Create a class to store a string. Include member functions to input and output the data member. Write the above program using constructor and destructor.

3. Write a C++ program by using the parameterized constructor.

4. Write a program by using the copy constructor concept to accept a number display that number.

5. Implement and test a class complex to store
.Real
.Imaginary

Include following constructors
.Default (to initialize both data members by zero value)
. One argument (to initialize both data members by a single value)
.Multiple argument (to initialize both data members by different value)
· Copy

Include destructor

6. Create a class to store string dynamically
Include following constructors
· Default (to initialize string to null value)
· One argument (to initialize string by a given value)
· Copy

7. WAP to implement a polynomial class having data members’ coefficient, base and power. For example, the polynomial 2x5 has the coefficient 2, base x and power 5. Include default and parameterized constructor and also include a member function evaluate () to find the value of the polynomial.

For example, if the polynomial is 2x5.
X=2, 2x5=64 is the answer.

Monday, February 16, 2009

Assignment-6

Q.1: Program to add two complex numbers using objects as arguments.

Q.2: Program to add time in hour and min using objects as argument.

Q.3. Create a class using friend function to calculate the mean of two values and parameter for the mean function should be object of the same class.

Q4.Create two classes using friend function i.e max to find the maximum value and parameters for the max function are two objects of the two classes.

Q.5.A library uses computer based information system for keeping track of its collection. With each book the information system stores the following information.
(i) Accession no of the book (an integer)
(ii) issue code with I,B,L,A indicating issued to a member, send for binding, Issued to another library and available respectively
(iii) Identity of the member which is an alphanumeric quantity.

The services extended by the library are
(a) Provides status of a requested book
(b) Provides list of all issued book

Q.6. Create two classes A & B with data members i and j respectively. Include friend function swap () to swap the values in the data members of the two classes.

Q.7.WAP to count and display the number of objects created in a class. (Use static variable)
(c) Provides list of books issued to a member

Friday, January 30, 2009

OOPS ASSIGNMENT- 5

1. Create a class A with data members i and j respectively. Include a function swap () to swap the values in the data members.


2. WAP to calculate simple interest by passing the principal amount, rate of interest and time period as argument to function. Make rate of interest and time period default argument with default values 1.2 and 3 respectively


3. Raising a number n to power p is the same as multiplying by itself t times. Write a function called power ( ) that makes a double value for n and an int value for p and returns the result as double value. Use default argument of 2 for p, so that if this argument is omitted, the number will be squared. Write a main( ) function that gets values
from the user to test this function.


4 Write a function “increment” which takes two arguments and increment the first argument by second pass the argument to this function from main and print the increment value in the main function (use reference variable).

Friday, January 23, 2009

OOP ASSIGNMENT - 4

1. Write a class “employee” to store following information Name, employee ID, Age, Marital Status, and Salary. WAP to store information for 3 employees and display the results.

2. Implement a class “number” having data members value This class has a member function FindDigit() to count the occurrences of each digit in number object. Ex-If value = 1123, O/P = 1-Two times, 2 – One times and 3- One times

3.Define a class named Complex for representing complex numbers. A complex
number has the general form a + ib, where a is the real part and b is the imaginary
part (i stands for imaginary). Complex arithmetic rules are as follows:
(a + ib) + (c + id) = (a + c) + i(b + d)
(a + ib) – (c + id) = (a + c) – i(b + d)
(a + ib) * (c + id) = (ac – bd) + i(bc + ad)
Define these operations as member functions of Complex.

4. Create a string by using class , encrypt it & display it according to given instructions. A-Z, a-z, 0-9,’=’, ’,’, ’.’------- No changes. The space is replaced by ‘+’. Any other character is replaced by ‘%’ followed by ASCII value of that character.

Wednesday, January 21, 2009

OOPS ASSIGNMENT - 3

1. Write a program which inputs a positive integer n and outputs 2 raised to the power of n.

2. WAp to calculates the weekly gross pay for a worker, based on the total number of hours worked and the hourly payrate.

Hint. weeklyPay = workDays * workHours * payRate

3. Write a program which inputs a temperature reading expressed in Fahrenheit and outputs its equivalent in Celsius, using the formula:
°C = 5/9 (° F - 32)

Compile and run the program. Its behavior should resemble this:
Temperature in Fahrenheit: 41
41 degrees Fahrenheit = 5 degrees Celsius

4. Create a class to find the sum of two numbers. This includes two data members, three member functions to input , output the data members and to find the sum of two data members.

5. Create a class to find the multiplication of two matrices. This include three data members of type arrays, three member functions, one is to accept two matrices, other to display two matrices and 3rd one is to find the multiplication of two matrices and display the result.

6. Create a class time with data members to store hours, minutes and seconds. WAP to input two times and find their sum.

7. Implement a class “number” having data members value and include following member functions
(i) IsEven()->Checks whether the value is even or odd
(ii) Findfactorial()->to calculate the factorial of the number

Saturday, January 17, 2009

Interview questions

1. OOPS

OOPS Concepts-1

1.Describe the principles of OOPS
2.Explain the advantages of OOPs with the examples.
3.What are OOPS concepts? Explain with examples?
4.what do you mean by Generalization & realization in oops
5.What is method Overriding ? What is it in OOPS
6. What is method Overriding ? What is it in OOPS
7.what are the advantages of oops over traditional programming?
8.What are the advantages of inheritance?

Wednesday, January 14, 2009

OOPS ASSIGNMENT-2

Structure

1. Input student Name, Rollno, Branch, Age and telephoneno as a record through structure and display all the information.


2. Input Name, Degignation, Basic Salary of employee into the employee record and calculate

TA = 55% of Basic
DA = 65% of Basic
HRA = 35% of Basic
PF = 12% of Basic

Also calculate Group Salary and net salary

a) Use Array to structure to input minimum 3 records (3 persons data) and display all the records sequentially.
b Use pointer to structure to input minimum 3 records (3 persons data) and display all the records sequentially.


3. Input your date of Birth and current date through structure and calculate your age in Year, Month and days assume that 1 year = 365 days and 1 month = 30 days.

4. Create a student structure having data members roll, class & address, mark structure having data members roll, sub1, sub2, sub3 and a student detail structure having data members roll, class total marks, no of subject pass & overall pass. Those students who have appeared the exam, their information only stored in the mark structure array. Write a program which will collect the information & fill the data in student detail array depending on the pass criteria.

Saturday, January 10, 2009

OOPS ASSIGNMENT-1

Function and Array

1. WAP to swap two numbers using function.
2. WAP using function which outputs all the prime numbers between 2 and a given positive integer n:

Hint:
void Primes (unsigned int n);
A number is prime if it is only divisible by itself and 1.

3. WAP to define an enumeration called Month for the months of the year and use it to define a function which takes a month as argument and returns it as a constant string.

4. WAP to define a recursive version of the Power function

5. WAP to write a function which returns the sum of a list of real values

Hint:
double Sum (int n, double val ...);
where n denotes the number of values in the list.

6. The following table specifies the major contents of four brands of breakfast cereals.

Define a two-dimensional array to capture this data:
------------Fiber ----Sugar-----Fat------Salt
Top Flake--12g------25g -------16g-----0.4g
Cornabix---22g-------4g --------8g-----0.3g
Oatabix-----28g ------5g---------9g-----0.5g
Ultrabran---32g------7g---------2g------0.2g
Write a function which outputs this table element by element.

Monday, November 10, 2008

ORACLE Assignment-7

1.Write a query to display the current date. Label the column Date.
2.For each employee, display the employee number, last_name, salary, and salary increased by 15% and expressed as a whole number. Label the column New Salary. Place your SQL statement ina text file named lab3_2.sql.
3.Modify your query lab3_2.sql to add a column that subtracts the old salary fromthe new salary. Label the column Increase. Save the contents of the file as lab3_4.sql.Run the revised query.
4.Write a query that displays the employee’s last names with the first letter capitalized and all otherletters lowercase and the length of the name for all employees whose name starts with J, A, or M.Give each column an appropriate label. Sort the results by the employees’ last names.
5.For each employee, display the employee’s last name, and calculate the number of monthsbetween today and the date the employee was hired. Label the column MONTHS_WORKED. Orderyour results by the number of months employed. Round the number of months up to the closestwhole number.
6.Create a query to display the last name and salary for all employees. Format the salary to be 10characters long, left-padded with $. Label the column SALARY.
7.Using the DECODE function, write a query that displays the grade of all employees based on thevalue of the column JOB_ID, as per the following data:
JOB GRADE

AD_PRES A
ST_MAN B
IT_PROG C
SA_REP D
None of the above 0

Wednesday, October 29, 2008

Linux Interview Questions For software testers

oftware testing - Questions and Answers - Linix / Unix

1. Q. How do you list files in a directory?
A. ls - list directory contents
ls �l (-l use a long listing format)

2. Q. How do you list all files in a directory, including the hidden files?
A. ls -a (-a, do not hide entries starting with .)

3. Q. How do you find out all processes that are currently running?
A. ps -f (-f does full-format listing.)

4. Q. How do you find out the processes that are currently running or a particular user?
A. ps -au Myname (-u by effective user ID (supports names)) (a - all users)

5. Q. How do you kill a process?
A. kill -9 8 (process_id 8) or kill -9 %7 (job number 7)
kill -9 -1 (Kill all processes you can kill.)
killall - kill processes by name most (useful - killall java)


6. Q. What would you use to view contents of the file?
A. less filename
cat filename
pg filename
pr filename
more filename
most useful is command: tail file_name - you can see the end of the log file.

7. Q. What would you use to edit contents of the file?
A. vi screen editor or jedit, nedit or ex line editor

8. Q. What would you use to view contents of a large error log file?
A. tail -10 file_name ( last 10 rows)

9. Q. How do you log in to a remote Unix box?
A. Using telnet server_name or ssh -l ( ssh - OpenSSH SSH client (remote login program))

10.Q. How do you get help on a UNIX terminal?
A. man command_name
info command_name (more information)

11.Q. How do you list contents of a directory including all of its
subdirectories, providing full details and sorted by modification time?
A. ls -lac
-a all entries
-c by time

12.Q. How do you create a symbolic link to a file (give some reasons of doing so)?
A. ln /../file1 Link_name
Links create pointers to the actual files, without duplicating the contents of
the files. That is, a link is a way of providing another name to the same file.
There are two types of links to a file:Hard link, Symbolic (or soft) link;

13.Q. What is a filesystem?
A. Sum of all directories called file system.
A file system is the primary means of file storage in UNIX.
File systems are made of inodes and superblocks.

14.Q. How do you get its usage (a filesystem)?
A. By storing and manipulate files.

15.Q. How do you check the sizes of all users� home directories (one command)?
A. du -s
df


The du command summarizes disk usage by directory. It recurses through all subdirectories and shows disk usage by each subdirectory with a final total at the end.


Q. in current directory
A. ls -ps (p- directory; s - size)

16.Q. How do you check for processes started by user 'pat'?

A. ps -fu pat (-f -full_format u -user_name )

17.Q. How do you start a job on background?

A. bg %4 (job 4)

18 Q. What utility would you use to replace a string '2001' for '2002' in a text file?

A. Grep, Kde( works on Linux and Unix)

19. Q. What utility would you use to cut off the first column in a text file?
A. awk, kde

20. Q. How to copy file into directory?
A. cp /tmp/file_name . (dot mean in the current directory)

21. Q. How to remove directory with files?
A. rm -rf directory_name

22. Q. What is the difference between internal and external commands?
A. Internal commands are stored in the; same level as the operating system while external
commands are stored on the hard disk among the other utility programs.

23. Q. List the three main parts of an operating system command:
A. The three main parts are the command, options and arguments.

24 Q. What is the difference between an argument and an option (or switch)?
A. An argument is what the command should act on: it could be a filename,
directory or name. An option is specified when you want to request additional
information over and above the basic information each command supplies.

25. Q. What is the purpose of online help?
A. Online help provides information on each operating system command, the
syntax, the options, the arguments with descriptive information.
26. Q. Name two forms of security.
A. Two forms of security are Passwords and File Security with permissions specified.

27. Q. What command do you type to find help about the command who?
A. $ man who

28. Q. What is the difference between home directory and working directory?
A. Home directory is the directory you begin at when you log into the
system. Working directory can be anywhere on the system and it is where you are currently
working.

29. Q. Which directory is closer to the top of the file system tree, parent directory or current directory?
A. The parent directory is above the current directory, so it is closer to
the root or top of the
file system.

30. Q. Given the following pathname:
$ /business/acctg/payable/supplier/april
a) If you were in the directory called acctg, what would be the relative
pathname name for the file called april?
b) What would be the absolute pathname for april?
A.
a) $ payable/supplier/april
b) $ /business/acctg/payable/supplier/april

31. Q. Suppose your directory had the following files:
help. 1 help.2 help.3 help.4 help.O1 help.O2
aid.O1 aid.O2 aid.O3 back. 1 back.2 back.3
a) What is the command to list all files ending in 2?
b) What is the command to list all files starting in aid?
c) What is the command to list all "help" files with one character extension?
A.
a) ls *2
b) ls aid.*
c) ls help.?

32. Q. What are two subtle differences in using the more and the pg commands?
A. With the more command you display another screenful by pressing
the spacebar, with pg you press the return key.
The more command returns you automatically to the UNIX
shell when completed, while pg waits until you press return.

33. Q. When is it better to use the more command rather than cat command?
A. It is sometimes better to use the more command when you are viewing
a file that will display over one screen.

34. Q. What are two functions the move mv command can carry out?
A. The mv command moves files and can also be used to rename a file or directory.

35. Q. Name two methods you could use to rename a file.
A. Two methods that could be used:
a. use the mv command
b. copy the file and give it a new name and then remove the original file if no longer needed.

36. The soccer league consists of boy and girl teams. The boy file names begin
with B, the girl teams begin with G. All of these files are in one directory
called "soccer", which is your current directory:
Bteam.abc Bteam.OOl Bteam.OO2 Bteam.OO4
Gteam.win Gteam.OOl Gteam.OO2 Gteam.OO3
Write the commands to do the following:
a) rename the file Bteam.abc to Bteam.OO3.
b) erase the file Gteam. win after you have viewed the contents of the file
c) make a directory for the boy team files called "boys", and one for the girl team files
called" girls"
d) move all the boy teams into the "boys" directory
e) move all the girl teams into the "girls" directory
f) make a new file called Gteam.OO4 that is identical to Gteam.OOl
g) make a new file called Gteam.OO5 that is identical to Bteam.OO2
A.
a) mv Bteam.abc Bteam.OO3.
b) cat Gteam.win -or- more Gteam.win
rm Gteam. win
c) mkdir boys
mkdir girls
d) mv Bteam* boys
e) mv Gteam* girls
f) cd girls
cp Gteam.OO1 Gteam.OO4
g) There are several ways to do this. Remember that we are currently in the directory
/soccer/girls.
cp ../boys/Bteam.OO2 Gteam.OO5
or
cd ../boys
cp Bteam.OO2 ../girls/Gteam.OO5


37. Q. Draw a picture of the final directory structure for the "soccer"
directory, showing all the files and directories.


38. Q. What metacharacter is used to do the following:
1.1 Move up one level higher in the directory tree structure
1.2 Specify all the files ending in .txt
1.3 Specify one character
1.4 Redirect input from a file
1.5 Redirect the output and append it to a file
A.
1. 1.1 double-dot or ..
1.2 asterisk or *
1.3 question or ?
1.4 double greater than sign: >>
1.5 the less than sign or <

39. Q. List all the files beginning with A
A. To list all the files beginning with A command: ls A*


40. Q. Which of the quoting or escape characters allows the dollar sign ($) to retain its special meaning?
A. The double quote (") allows the dollar sign ($) to retain its special meaning.
Both the backslash (\) and single quote (') would remove the special meaning of the dollar sign.

41. Q. What is a faster way to do the same command?
mv fileO.txt newdir
mv filel.txt newdir
mv file2.txt newdir
mv file3.txt newdir
A. A shortcut method would be: mv file?.txt newdir


42. Q. List two ways to create a new file:
A.
a. Copy a file to make a new file.
b. Use the output operator e.g. ls -l > newfile.txt

43. Q. What is the difference between > and >> operators?
A. The operator > either overwrites the existing file (WITHOUT WARNING) or creates a new file.
The operator >> either adds the new contents to the end of an existing file or creates a new file.

44. Write the command to do the following:
44.1 Redirect the output from the directory listing to a printer.
44.2 Add the file efg.txt to the end of the file abc.txt.
44.3 The file testdata feeds information into the file called program
44.4 Observe the contents of the file called xyz.txt using MORE.
44.5 Observe a directory listing that is four screens long.
A.
44.1 ls > lpr
44.2 cat efg.txt >> abc.txt
44.3 program < testdata
44.4 more < xyz.txt
44.5 ls > dirsave | more



45. Q. How do you estimate file space usage
A. Use du command (Summarize disk usage of each FILE, recursively for
directories.) Good to use arguments du -hs
(-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
(-s, --summarize display only a total for each argument)

46. Q. How can you see all mounted drives?
A. mount -l

47. Q. How can you find a path to the file in the system?
A. locate file_name (locate - list files in databases that match a pattern)

48. Q. What Linux HotKeys do you know?
A. Ctrl-Alt-F1 Exit to command prompt
Ctrl-Alt-F7 or F8 Takes you back to KDE desktop from command prompt
Crtl-Alt-Backspace Restart XWindows
Ctrl-Alt-D Show desktop

49. Q. What can you tell about the tar Command?
A. The tar program is an immensely useful archiving utility. It can combine
an entire directory tree into one large file suitable for transferring or
compression.

50. Q. What types of files you know?
A. Files come in eight flavors:
Normal files
Directories
Hard links
Symbolic links
Sockets
Named pipes
Character devices
Block devices

51. Q. How to copy files from on PC to another on the same network
A. Use the following command:scp yur_file you_login@your_IP
example: copy .conf file from your PC to alex computer-
scp /etc/X11/xorg.conf alex@10.0.10.169:

52. Q. Please describe information below:

-rw-rw-r-- 1 dotpc dotpc 102 Jul 18 2003 file.buf
drwxr-xr-x 9 dotpc dotpc 4096 Oct 21 09:34 bin
lrwxrwxrwx 1 dotpc dotpc 20 Mar 21 15:00 client -> client-2.9.5
drwxrwxr-x 11 dotpc dotpc 4096 Sep 2 2005 client-2.8.9
drwxrwxr-x 7 dotpc dotpc 4096 Dec 14 12:13 data
drwxr-xr-x 12 dotpc dotpc 4096 Oct 21 09:41 docs
drwxr-xr-x 5 dotpc dotpc 4096 Dec 7 14:22 etc
drwxr-xr-x 11 dotpc dotpc 4096 Mar 21 15:54 client-2.9.5
-rw-r--r-- 1 dotpc dotpc 644836 Mar 22 09:53 client-2.9.5.tar.gz

A. This is a result of command $ls -l
we have two files, 6 directories and one link to client-2.9.5 directory.
There is number of files in every directory, size and data of last change.


53. Q. If you would like to run two commands in sequence what operators you can use?

A. ; or && the difference is:
if you separate commands with ; second command will be run automatically.
if you separate commands with && second command will be run only in the case
the first was run successfully.

54. Q. How you will uncompress the file?
A. Use tar command (The GNU version of the tar archiving utility):
tar -zxvf file_name.tar.gz

55. Q.How do you execute a program or script, my_script in your current directoty?
A. ./my_script

56. Q.How to find current time configuration in the file my_new.cfg
A. grep time my_new.cfg
Grep searches the named input files (or standard input if
no files are named, or the file name - is given) for lines
containing a match to the given pattern.

Q. What does grep() stand for?
A. General Regular Expression Parser.

57. Q. What does the top command display?
A. Top provides an ongoing look at processor activity in real
time. It displays a listing of the most CPU-intensive
tasks on the system, and can provide an interactive inter­
face for manipulating processes. (q is to quit)

58. Q. How can you find configuration on linux?
A. by using /sin/ifconfig
If no arguments are given, ifconfig displays the status of the cur-
rently active interfaces. If a single interface argument is given, it displays the status of the given interface only; if a single -a argu-
ment is given, it displays the status of all interfaces, even those
that are down. Otherwise, it configures an interface.

59. Q. How to find difference in two configuration files on the same server?
A. Use diff command that is compare files line by line
diff -u /usr/home/my_project1/etc/ABC.conf /usr/home/my_project2/etc/ABC.conf

60. Q. What is the best way to see the end of a logfile.log file?
A. Use tail command - output the last part of files
tail -n file_name ( the last N lines, instead of the last 10 as default)

61. Q. Please write a loop for removing all files in the current directory that contains a word 'log'
A. for i in *log*; do rm $i; done

62. Question: How to switch to a previously used directory?
Answer: cd -


1.   Q.How many VI editor modes do you know?
A.Three modes -
Command mode: letters or sequence of letters interactively command vi.
Insert mode: Text is inserted.
Command line mode: enter this mode by typing ":" and entry command line at the foot of the screen.

2. Q. How can you terminate VI session?
A.
  • Use command: ZZ that is save changes and quit.
  • Use command line: ":wq" that is write changes and quit.
  • Use command line: ":q!" to ignore changes and quit.

    3. Q. How can you copy lines into the buffer in command mode?
    A.
    yy - copy a single line defined by current cursor position
    3yy - copy 3 lines. Current line and two lines below it.


  • Oracle function 1

    Oracle functions

    Sysdate:- returns current date and time.

    Avg(n):- returns average ignoring null value.

    Sum(n):- returnas sum values

    Max (expr) :- returns maximum vaule of the expression

    Min(expr): - returns minimum value of the expression

    Count(*):- returns the number of the rows including the duplicate and the nulls.

    Power(m,n):- returns the power of the value.

    Round(n,m):-returns n rounded to n places.

    Sqrt(n):returns the sqrt of the n.String function:-

    Lower(char):-returns char with lower case.

    Upper(char):-returns char with upper case.

    Initcap(char):returns string with first letter with upper case.

    Substr(char,m,n):- returns the substring beginning with position m upto n characters

    Length(char):-reutrns the length of the string.

    Ltrim(string,trim_string):- string1 is the string to trim the characters from the left-hand sidetrim_string is the string that will be removed from the left-hand side of string1. If this parameter is omitted, the ltrim function will remove all leading spaces from string1.

    Rtrim(string,rtrim_string)string1 is the string to trim the characters from the right-hand side.trim_string is the string that will be removed from the right-hand side of string1. If this parameter is omitted, the rtrim function will remove all trailing spaces from string1.

    Lpad(char1,n,char2):-returns char 1 left padded to length ‘n’ with sequence of characters in ‘char2’Rpad(char1.n.char2):returns char 1 right padded to length n with sequence of character in ‘char2’

    oracle assgn 5


    1. Display the highest, lowest, sum, and average salary of all employees. Label the columns Maximum, Minimum, Sum, and Average, respectively. Place your SQL statement in a text file named lab5_1.sql.
    2. Display highest, lowest, average salary of the employees whose job ID contains keyword R&D.

    3. Count the total number of employees whose department_id =50

    4. Display the number of department values in the EMPLOYEES table.

    5. Display the number of distinct department values in the EMPLOYEES table.

    6. Display the average salaries for each department

    7. Display the total salary of the employees for each job on each department.

    8. Display the average salary above 8000 of the employees for each department.

    9. Display the maximum salary above 8000 for each department.

    10. Display the job ID and total monthly salary for each job with a total payroll exceeding $13,000. sort the list by the total monthly salary.

    11. Display the maximum average salary for each department.

    12. Write a query to display the number of people with the same job.

    13 Determine the number of managers without listing them. Label the column Number of Managers. Hint: Use the MANAGER_ID column to determine the number of managers.

    14. Write a query that displays the difference between the highest and lowest salaries. Label the column DIFFERENCE.

    15. Display the manager number and the salary of the lowest paid employee for that manager. Exclude anyone whose manager is not known. Exclude any groups where the minimum salary is $6,000 or less. Sort the output in descending order of salary.

    Saturday, October 25, 2008

    UNIX VI EDITOR COMMANDS

    The vi editor (short for visual editor) is a screen editor which is available on almost all Unix systems
    Starting vi:--To start using vi, at the Unix prompt type vi followed by a file name
    vi has two modes: the command mode and the insert mode.
    Entering Text:::To begin entering text in an empty file, you must first change from the command mode to the insert mode. To do this, type the letter i.

    write a c program in the vi editor

    then press escape key->type :wq

    compile the file: cc filename

    Run the program: ./a.out

    User commands
    Arrow keys:Move cursor

    hjkl:Same as arrow keys

    Presss escape and execute the commands

    x:delete a character
    dw:delete a word
    dd:delete a line
    3dd:deletes 3 lines
    u:undo previous change

    Now go to command mode by pressing ESC key

    :q - quit, without saving

    :wq - save and quit


    F- forward screen

    ^B-backward screen
    ^D-scroll down half screen
    ^U-scroll up half screen



    (-beginning of sentence
    )-end of sentence
    {-beginning of paragraph
    }-end of paragraph

    Saturday, September 27, 2008

    ORACLE ASSGN-4

    1. Create a query to display the last name and salary of employees earning more than $12,000.
    Place your SQL statement in a text file named lab4_1.sql. Run your query.
    2. Create a query to display the employee last name and department number for employee number
    176.
    3. Modify lab4_1.sql to display the last name and salary for all employees whose salary is
    not in the range of $5,000 and $12,000. Place your SQL statement in a text file named lab4_3.sql

    4. Display the employee last name, job ID, and start date of employees hired between February
    20, 1998, and May 1, 1998. Order the query in ascending order by start date.
    5. Display the last name and department number of all employees in departments 20 and 50 in
    alphabetical order by name.
    6. Modify lab4_3.sql to list the last name and salary of employees who earn between $5,000
    and $12,000, and are in department 20 or 50. Label the columns Employee and Monthly
    Salary, respectively. Resave lab4_3.sql as lab4_6.sql. Run the statement in
    lab4_6.sql.
    7. Display the last name and hire date of every employee who was hired in 1994.
    8. Display the last name and job title of all employees who do not have a manager.
    9. Display the last name, salary, and commission for all employees who earn commissions. Sort
    data in descending order of salary and commissions.
    10. Display the last names of all employees where the third letter of the name is an a.
    11. Display the last name of all employees who have an a and an e in their last name.
    12. Display the last name, job, and salary for all employees whose job is sales representative or
    stock clerk and whose salary is not equal to $2,500, $3,500, or $7,000.
    13. Modify lab4_6.sql to display the last name, salary, and commission for all employees
    whose commission amount is 20%. Resave lab4_6.sql as lab4_13.sql. Rerun the
    statement in lab4_13.sql.

    Thursday, September 25, 2008

    ORACLE ASSIGN-3

    1. Add a table-level PRIMARY KEY constraint to the EMP table on the ID column. The constraint should be named at creation. Name the constraint my_emp_id_pk

    2. Create a PRIMARY KEY constraint to the DEPT table using the ID column. The constraint
    should be named at creation. Name the constraint my_dept_id_pk.

    3. Add a column DEPT_ID to the EMP table. Add a foreign key reference on the EMP table that ensures that the employee is not assigned to a nonexistent department. Name the constraint
    my_emp_dept_id_fk.

    4.Confirm that the constraints were added by querying the USER_CONSTRAINTS view. Note the types and names of the constraints.

    5. Display the object names and types from the USER_OBJECTS data dictionary view for the EMP and DEPT tables. Notice that the new tables and a new index were created.

    6. Modify the EMP table. Add a COMMISSION column of NUMBER data type, precision 2, scale 2. Add a constraint to the commission column that ensures that a commission value is greater than zero.

    7.Create the EMPLOYEES2 table based on the structure of the EMPLOYEES table. Include only
    the EMPLOYEE_ID, FIRST_NAME, LAST_NAME, SALARY, and DEPARTMENT_ID columns.
    Name the columns in your new table ID, FIRST_NAME, LAST_NAME, SALARY , and
    DEPT_ID, respectively.

    8. Create the DEPT table based on the following table instance chart, then execute the statement in the script to create the table. Confirm that the table is created.
    ID NUMBER 7
    NAME VARCHAR2 25

    9. Populate the DEPT table with data from the DEPARTMENTS table. Include only columns that
    you need.