of 62
7/30/2019 Ajay Practical File
1/62
INFORMATION TECHNOLOGY
FOR MANAGERS
PRACTICAL FILESubmitted for partial fulfillment for the award of the
Degree of:-
MASTER OF BUSINESS ADMINISTRATION
(MBA 2011-2013)
Under the supervision of
MS Ranjeeta Popli
Submitted by
AJAY JAIN
ENROLLMENT NO. 075
GITARATTAN INTERNATIONAL BUSINESS SCHOOL
(Affiliated to Guru Gobind Singh Indraprastha
University)
Madhuban Chowk, ROHINI, DELHI - 110085
1
7/30/2019 Ajay Practical File
2/62
TABLE OF CONTENTS
Topics Page No.
1. MS-DOS 03 - 18
2. HTML 19 - 28
3. SPREADSHEETS 29 - 48
4. SQL 49 - 62
2
7/30/2019 Ajay Practical File
3/62
MS-DOS
3
7/30/2019 Ajay Practical File
4/62
Disk Operating System (DOS)
DOS was developed by Microsoft Primarily as a single user operating system
working on Personal Computers. From 1981 till now many versions starting
version 1.0 till 6.2 have been released. Each successive version had itsenhancements aimed at improving the management of the computer resources
available to the users.
Components of MS-DOS
MS-DOS consists of four essentials programs and a set of additional utilities. Fourmain programs are:
Boot Record
IO.SYS
MSDOS.SYS
COMMAND.COM
DOS Commands
A DOS command helps you to give instruction to the operating system in
Character User Interface (CUI) environment. Using DOS commands, you canperform various tasks, such as creating and managing files and folders andmonitoring your system resources.
To create and manage files and folders, perform the following steps:
1. Click the Startbutton, and then select Run.2. In the Run dialog box, type cmd in the Run box.3. Click the OKbutton.
4
7/30/2019 Ajay Practical File
5/62
The Command Prompt window is displayed.
In the Command Prompt window, the command is given after the commandprompt and the enter key is pressed to execute the command.
As the drive displayed is the user directory, change the drive to D: drive by giving
following command at the command prompt.
C:\Users\user>D:
Directories
In the DOS, each disk is organized into directories. Each Directory holds file. Thedefault directory is the Root Directory and contains the minimum DOS files.
The Root Directory cannot show more than 132 siles in its directory listing.
Create Directory
MD or MKDIR command is used to make direcotry.
5
7/30/2019 Ajay Practical File
6/62
Syntax:
MD [drive:] [path] [directory name]
Or
MKDIR [drive:] [path] [directory name]
Example:
To create new directory names Tom under C: drive, give following command:
C:\>MD Tom
Or
C:\>MKDIR Tom
Changing Directory
You can change your working directory by issuing the CD command.
Syntax:
CD [drive:] [directory name]
Example:To make Tom current directory, give following command:C:\>CD Tom
6
7/30/2019 Ajay Practical File
7/62
Deleting Directory
RD command is used to remove a directory.
Syntax:RD [drive:] [path]
Example:
To remove Tom directory from the C: drive, give the following command:C:\>RD Tom
Displaying Contents of a Directory
DIRcommand is used to display the contents of the directory.
Syntax:
DIR [drive:] [path] [/option]
/option stand for various options that can be used with DIR command which aredisplayed in the following table:
Option Description
/p Pause after each screenful/w Uses wide list format
/s Also look in subdirectories
Example:
To list the files and directories present under C: driveC:\>DIR/p
7
7/30/2019 Ajay Practical File
8/62
Creating text File
COPY CONcommand is used to create a text file.
Syntax:
COPY CON [filename]
After the command is given at the command prompt, the cursor goes to the nextline. Write the text and press Ctrl+Z key together to save the contents in the file.Then, press key.
Example:
To create a file client.txt under the current folderTom, give the command.C:\Tom>copy con Client.txt
Now, write
Hi,
How are you?
Then press Ctrl+Z and then, Enter key.
Displaying the Contents of a File
TYPE command is used to display the content of a file.
Syntax:
Type [drive:] [path] [filename]
8
7/30/2019 Ajay Practical File
9/62
Example:
C:\Tom>type Client.txt
Renaming File
REN command is used to change the name of a file.
Syntax:
REN [drive:] [path] [filename] [new filename]
Example:
To change the name of the file Client.txt to Client1.txt, give following command:C:\Tom>REN Client.txt Client1.txt
9
7/30/2019 Ajay Practical File
10/62
Copying Files
COPY command is used to copy one or more files to an alternate location.
Syntax:
COPY [source] [destination]
Source Specifies the path of the file or the files to be copied.Destination Specifies the path of the destination directory.
Example:
To copy Client1.txt the current Tom directory to giBS directory, give followingcommand:
C:\Tom>copy Client1.txt C:\giBS
Deleting FilesDEL command is used to delete file or files from the disk.Syntax:
DEL [drive:] [path] [filename]
Example:
To delete Jacob.txt from the giBS folder, give following command:C:\giBS>DEL Jacob.txt
10
7/30/2019 Ajay Practical File
11/62
Displaying Current Date
DATE command is used to display the current system date and prompt for enteringnew date.
Syntax:
DATE
Example:
C:\> Users>date
Displaying Current Time
TIME command is used to displays the current system Time and prompt forentering new time.
Syntax:TIME
Example:
C:\> Users>time
Clearing Command Prompt Screen
CLS command is used to clears the cluster screen.
11
7/30/2019 Ajay Practical File
12/62
Syntax:
CLS
Example:
C:\> CLS
Displaying the Path of the Directory
PATH command defines a list of directories DOS Searches for externalcommands.
Syntax:
PATH (Display the current Search Path)
Example:
C:\Users>path
External Commands
Copying Files
XCOPY command is faster than Copy Command and allows you to copyentire directories/disk including all the sub directories and files to destination.
Syntax:
XCOPY Source [Target] [/Y] [-Y] [/P] [/E]
12
7/30/2019 Ajay Practical File
13/62
Switches:
/-Y : Prompts before copying over existing files.
/y : Overwrites existing files without prompting.
/p : Ask before copying each file.
/e : Copying empty directory also.
/s : Copying subfolders.
Example:
XCOPY C:\tom D:\bob /S/E
Moving Files
MOVE command is used to move a file or files from one location to another
location.
Syntax:
MOVE [drive:] [source] [drive:] [target]
Example:
To move media.txt file from Tom to the directory giBS, give following command:C:\Tom>move media.txt C:\giBS
13
7/30/2019 Ajay Practical File
14/62
Comparing Files
FC Stands for File Compare. If you wish to compare two files or two sets of files
then you may use this command. This command has the capability to differentiatebetween the files and display the difference
Syntax:
FC [/a][/b][/c][l][/n]
Switches:
/a : This switch displays only the first and last line of each group.
/b : Compare the files in library mode ( byte-by-byte)
/c : Ignore the case of letters.
/l : Compare the files in text mode.
/n : Displays the line number for lines that are different.
Example:
FC first.txt second.txt\n
DOSKEY
Dos can remember only the last command you had entered. But in order tomake DOS remember all the commands you enter you will have to load aDOSKEY utility. Also Used To Create Macros
Syntax:
DOSKEY and Press
Display message on the screen.
DOSKEY Installed.
NOTE: - To display all commands from the history list on the screen.
Example:
DOSKEY / History or /h
14
7/30/2019 Ajay Practical File
15/62
7/30/2019 Ajay Practical File
16/62
DELTREE
This command used for deleting an entire directory whether in that directorycontains files or subdirectories and also it will delete hidden files.
Syntax:
DELTREE [drive:] [path] directories [/y]
EXAMPLE:
C:\> DELTREE my.txt
BATCH FILES
It is a collection of DOS commands to perform a certain task. or A batch file isnothing but sequence of commands to perform sequence of operations step by step.
Look at the following commands you give step by step to perform an operation.Suppose your job is
First - Check the directory TomSecond Make a new directory JobThird - Change directory to Job
If you do all this steps daily after your hour, then the commands you give wouldbe:
i) C:\tom> DIR ii) C:\tom> md jobiii) C:\tom>cd job
Instead of heating up your head daily giving the same set of commands you can doit in a much simpler manner. All you do is put all the commands in a Batch file.
How to create a batch file:
C:\tom> COPY CON A.bat Note:Here Con means Console that is Keyboard, A the file name and .bat is extension.
It is compulsory that a batch file must have extension .BAT.16
7/30/2019 Ajay Practical File
17/62
You will find the cursor below A now type
C:\tom> DIR C:\tom>md job C:\tom> cd job^Z
EDIT
This is the DOS Editor, which you can use to edit the text file and also creatingnew file.
Syntax:Edit [drive:] [path] [filename]
Example:
C:\tom> EDIT jack.txt
17
7/30/2019 Ajay Practical File
18/62
18
7/30/2019 Ajay Practical File
19/62
HTML
19
7/30/2019 Ajay Practical File
20/62
Introduction
Hypertext markup language (HTML) is a markup languagethat web browsers use
to interpret and compose text, images and other material into visual or audible web
pages. It is developed by World Wide Web consortium (W3C).
It is not a programming Language. HTML is the set of markup tags.
Extension of HTML files is .htm or.html.
HTML Tags
HTML markup tags are usually called HTML tags
HTML tags are keywords surrounded by angle brackets like HTML tags normally come in pairs like and The first tag in a pair is the start tag, the second tag is the end tag Start and end tags are also called opening tags and closing tags
HTML Element Syntax
An HTML element starts with a start tag / opening tag
An HTML element ends with an end tag / closing tag The element content is everything between the start and the end tag Some HTML elements have empty content Empty elements are closed in the start tag Most HTML elements can have attributes
HTML Attributes
HTML elements can have attributes Attributes provide additional information about an element
Attributes are always specified in the start tag Attributes come in name/value pairs like: name="value"
Getting started with Examples.
HTML Headings
20
http://en.wikipedia.org/wiki/Markup_languagehttp://en.wikipedia.org/wiki/Web_browserhttp://en.wikipedia.org/wiki/Typesettinghttp://en.wikipedia.org/wiki/Markup_languagehttp://en.wikipedia.org/wiki/Web_browserhttp://en.wikipedia.org/wiki/Typesetting7/30/2019 Ajay Practical File
21/62
Headings are defined with the to tags.
defines the most important heading. defines the least importantheading.
Save this file in [filename].html.
HTML Lines
The tag creates a horizontal line in an HTML page.
21
7/30/2019 Ajay Practical File
22/62
Output
HTML Text Formatting
tag is used forbold the text.
22
7/30/2019 Ajay Practical File
23/62
tag is used foritalic the text.
tag is used for underline the text.
Output
HTML Fonts
23
7/30/2019 Ajay Practical File
24/62
Output
HTML Style
24
7/30/2019 Ajay Practical File
25/62
Output
HTML Links
is used for HTML link.
25
7/30/2019 Ajay Practical File
26/62
Output
HTML Images
26
7/30/2019 Ajay Practical File
27/62
Output
27
7/30/2019 Ajay Practical File
28/62
HTML Tables
A table is divided into rows (with the tag), and each row is divided into data
cells (with the tag). td stands for "table data," and holds the content of a data
cell. A tag can contain text, links, images, lists, forms, other tables, etc.
Output
28
7/30/2019 Ajay Practical File
29/62
SPREADSHEETS
29
7/30/2019 Ajay Practical File
30/62
INTRODUCTION
Spreadsheet applications (sometimes referred to simply asspreadsheets) are
computerprograms that let you create and manipulate spreadsheets electronically.In a spreadsheet application, each value sits in a cell. You can define what type of
data is in each cell and how different cells depend on one another. The
relationships between cells are calledformulas, and the names of the cells are
called labels.
Some examples of spreadsheet usage:
Spreadsheets act like a calculator by automatically doing calculations.
Spreadsheets are used for tracking personal investments, budgeting,invoices, inventory tracking, statistical analysis, numerical modeling,address books, telephone books, printing labels, etc.
Spreadsheets are used in almost every profession to calculate, graph, analyzeand store information.
Spreadsheets are used for What-if calculations. Change one number in aspreadsheet and all the calculations in a large spreadsheet will re-calculate,will automatically change.
There are a number of spreadsheet on the market, Lotus 1-2-3 and Excelbeingamong the most famous. The more powerful spreadsheet applications support
graphicsfeatures that enable you to produce charts and graphs from the data.
Here we will discuss about MS-EXCEL.
Microsoft Excel is aproprietarycommercialspreadsheet application written and
distributed by Microsoft forMicrosoft Windows and Mac OS.
Excel forms part ofMicrosoft Office. The current versions are 2010 forMicrosoft
Windows and 2011 forMac OS X.
30
http://www.webopedia.com/TERM/C/computer.htmlhttp://www.webopedia.com/TERM/P/program.htmlhttp://www.webopedia.com/TERM/A/application.htmlhttp://www.webopedia.com/TERM/C/cell.htmlhttp://www.webopedia.com/TERM/D/data.htmlhttp://www.webopedia.com/TERM/F/formula.htmlhttp://www.webopedia.com/TERM/N/name.htmlhttp://www.webopedia.com/TERM/L/label.htmlhttp://www.webopedia.com/TERM/L/Lotus_1_2_3.htmlhttp://www.webopedia.com/TERM/S/support.htmlhttp://www.webopedia.com/TERM/G/graphics.htmlhttp://www.webopedia.com/TERM/F/feature.htmlhttp://en.wikipedia.org/wiki/Proprietary_softwarehttp://en.wikipedia.org/wiki/Commercial_softwarehttp://en.wikipedia.org/wiki/Spreadsheethttp://en.wikipedia.org/wiki/Microsofthttp://en.wikipedia.org/wiki/Microsoft_Windowshttp://en.wikipedia.org/wiki/Microsoft_Officehttp://en.wikipedia.org/wiki/Microsoft_Windowshttp://en.wikipedia.org/wiki/Microsoft_Windowshttp://en.wikipedia.org/wiki/Mac_OS_Xhttp://www.webopedia.com/TERM/C/computer.htmlhttp://www.webopedia.com/TERM/P/program.htmlhttp://www.webopedia.com/TERM/A/application.htmlhttp://www.webopedia.com/TERM/C/cell.htmlhttp://www.webopedia.com/TERM/D/data.htmlhttp://www.webopedia.com/TERM/F/formula.htmlhttp://www.webopedia.com/TERM/N/name.htmlhttp://www.webopedia.com/TERM/L/label.htmlhttp://www.webopedia.com/TERM/L/Lotus_1_2_3.htmlhttp://www.webopedia.com/TERM/S/support.htmlhttp://www.webopedia.com/TERM/G/graphics.htmlhttp://www.webopedia.com/TERM/F/feature.htmlhttp://en.wikipedia.org/wiki/Proprietary_softwarehttp://en.wikipedia.org/wiki/Commercial_softwarehttp://en.wikipedia.org/wiki/Spreadsheethttp://en.wikipedia.org/wiki/Microsofthttp://en.wikipedia.org/wiki/Microsoft_Windowshttp://en.wikipedia.org/wiki/Microsoft_Officehttp://en.wikipedia.org/wiki/Microsoft_Windowshttp://en.wikipedia.org/wiki/Microsoft_Windowshttp://en.wikipedia.org/wiki/Mac_OS_X7/30/2019 Ajay Practical File
31/62
Step of Opening Ms-Excel
Start All Programs - Microsoft Office Microsoft Office Excel
Or
Start Run type excel and press OK
The first page of Microsoft Excel 2007
31
7/30/2019 Ajay Practical File
32/62
Worksheets
Microsoft Excel consists ofworksheets. Each worksheet contains columns and
rows.The columns are lettered A to Z and then continuing with AA, AB, AC and
so on; the rows are numbered 1 to 1,048,576.
The Formula Bar
If the Formula bar is turned on, the cell address of the cell you are in displays inthe Name box which is located on the left side of the Formula bar. Cell entriesdisplay on the right side of the Formula bar.
32
http://www.baycongroup.com/excel2007/01_excel.htmhttp://www.baycongroup.com/excel2007/01_excel.htm7/30/2019 Ajay Practical File
33/62
The Status Bar
The Status bar appears at the very bottom of the Excel window and provides suchinformation as the sum, average, minimum, and maximum value of selectednumbers. You can change what displays on the Status bar by right-clicking on theStatus bar and selecting the options you want from the Customize Status Bar menu.You click a menu item to select it.
Excel Formulas
A formula is a set of mathematical instructions that can be used in Excel toperform calculations. Formals are started in the formula box with an = sign.
33
7/30/2019 Ajay Practical File
34/62
There are many elements to and excel formula.
References: The cell or range of cells that you want to use in your calculationOperators: Symbols (+, -, *, /, etc.) that specify the calculation to be performed
Constants: Numbers or text values that do not changeFunctions: Predefined formulas in Excel
To create a basic formula in Excel:
Select the cell for the formula Type = (the equal sign) and the formula ClickEnter
Calculate with Functions
A function is a built in formula in Excel. A function has a name and arguments(the mathematical function) in parentheses.
34
7/30/2019 Ajay Practical File
35/62
Common functions in Excel:
Sum: Adds all cells in the argumentAverage: Calculates the average of the cells in the argument
Min: Finds the minimum valueMax: Finds the maximum valueCount: Finds the number of cells that contain a numerical value within a range ofthe argument
To calculate a function:
Click the cell where you want the function applied Click the Insert Functionbutton Choose the function ClickOK
Complete the Number 1 box with the first cell in the range that you wantcalculated
Complete the Number 2 box with the last cell in the range that you wantcalculated
35
7/30/2019 Ajay Practical File
36/62
Function Library
The function library is a large group of functions on the Formula Tab of theRibbon. These functions include:
AutoSum: Easily calculates the sum of a rangeRecently Used: All recently used functionsFinancial: Accrued interest, cash flow return rates and additional financial
functionsLogical: And, If, True, False, etc.Text: Text based functionsDate & Time: Functions calculated on date and timeMath & Trig: Mathematical Functions
36
7/30/2019 Ajay Practical File
37/62
Sort and Filter
Sorting and Filtering allow you to manipulate data in a worksheet based on givenset of criteria.
Basic Sorts
To execute a basic descending or ascending sort based on one column:
Highlight the cells that will be sorted Click the Sort & Filter button on the Home tab Click the Sort Ascending (A-Z) button orSort Descending (Z-A) button
37
7/30/2019 Ajay Practical File
38/62
Custom Sorts
To sort on the basis of more than one column:
Click the Sort & Filter button on the Home tab Choose which column you want to sort by first ClickAdd Level Choose the next column you want to sort ClickOK
38
7/30/2019 Ajay Practical File
39/62
Filtering
Filtering allows you to display only data that meets certain criteria. To filter:
Click the column or columns that contain the data you wish to filter On the Home tab, click on Sort & Filter Click Filter button Click the Arrow at the bottom of the first cell Click the Text Filter Click the Words you wish to Filter
39
7/30/2019 Ajay Practical File
40/62
To clear the filter click the Sort & Filter button ClickClear
Charts
Charts allow you to present information contained in the worksheet in a graphicformat. Excel offers many types of charts including: Column, Line, Pie, Bar, Area,Scatter and more. To view the charts available click the Insert Tab on the Ribbon.
Create a Chart
To create a chart:
Select the cells that contain the data you want to use in the chart Click the Insert tab on the Ribbon Click the type ofChart you want to create
Modify a Chart
Once you have created a chart you can do several things to modify the chart.
40
7/30/2019 Ajay Practical File
41/62
To move the chart:
Click the Chart and Drag it another location on the same worksheet, or Click the Move Chart button on the Design tab Choose the desired location (either a new sheet or a current sheet in the
workbook)
To change the data included in the chart:
Click the Chart Click the Select Data button on the Design tab
To reverse which data are displayed in the rows and columns:
41
7/30/2019 Ajay Practical File
42/62
Click the Chart Click the Switch Row/Column button on the Design tab
To modify the labels and titles:
Click the Chart On the Layout tab, click the Chart Title or the Data Labels button Change the Title and clickEnter
Chart Tools
The Chart Tools appear on the Ribbon when you click on the chart. The tools are
42
7/30/2019 Ajay Practical File
43/62
located on three tabs: Design, Layout, and Format.
Within the Design tab you can control the chart type, layout, styles, and location.
Within the Layout tab you can control inserting pictures, shapes and text boxes,
labels, axes, background, and analysis.
Within the Format tab you can modify shape styles, word styles and size of thechart.
Copy a Chart to Word
43
7/30/2019 Ajay Practical File
44/62
Select the chart ClickCopy on the Home tab Go to the Word document where you want the chart located ClickPaste on the Home tab
Pivot Table
AnExcel pivot table is a special kind of table that assembles and summarizesinformation from a designated data source. That data source can be an external fileor it can be a selection of cells in a worksheet.
When creating the pivot table, you specify what fields need to appear and how toorganize the data in the table. Once created, you can change the way that the data issummarized to give you a different view of your information, and it is this feature
that puts the pivot in pivot table.
In this example the source data contains information about property insurancepolicies. Each row has the details about one insurance policy, such as the region,state, construction type and the value of the insured property.
44
7/30/2019 Ajay Practical File
45/62
Creating a Simple Pivot Table
After your source data is prepared, you can create a pivot table. We'll create a pivottable that shows the total insured value in each of the four regions where we sellinsurance.
1. Select any cell in the source data table.2. On the Ribbon, click the Insert tab.3. In the Tables group, click PivotTable.
45
7/30/2019 Ajay Practical File
46/62
4. In the Create PivotTable dialog box, the address of your source data tableshould be automatically entered in the Table/Range box. If not, click on theworksheet, and select the range manually.
5. Next, select New Worksheet or Existing Worksheet as the location for yourpivot table, and then click OK.
Adding Fields to the Pivot Table
An empty pivot table is created in your workbook, either on a new sheet, or theexisting sheet that you selected. When you select a cell within the pivot table, aPivotTable Field List appears, at the right of the worksheet.
46
7/30/2019 Ajay Practical File
47/62
We want to see the total insured value in each of the four regions, so we'll add theRegion and Insured Value fields to the pivot table.
1. In the PivotTable Field List, add a check mark to the Region field. The
Region field is automatically added to the pivot table, in the Row Labelsarea.
2. Add a check mark to the Price field, and it will be automatically added to theValues area. You can now see the total price value in each region.
47
7/30/2019 Ajay Practical File
48/62
Modifying the Pivot Table
After you've created a pivot table, you can add more fields, remove fields, or movethe fields to a different location in the pivot table layout. We'll remove the Regionfield, and add the Gender field, to see the boys sales compared to Girls.
1. To remove the Region field, click on its check box, to remove the checkmark.
2. To add the Gender field, click on its check box, to add a check mark.
The pivot table now shows the totals for Boys and Girls.
48
7/30/2019 Ajay Practical File
49/62
SQL
49
7/30/2019 Ajay Practical File
50/62
Database
A database is a structured collection of data.
The term database is correctly applied to the data and their supporting data
structures, and not to the database management system (DBMS). The database data
collection with DBMS is called a database system.
Database Management System (DBMS)
Database-oriented approach of organizing data provides a set of programs to
facilitate users to organize, create, delete, update, and manipulate data in a
database.
All these programs together form aDatabase Management System (DBMS).
Database models
Database model defines the manner in which a database links its various data
element together.
There are three models in use:
Hierarchical
Network
Relational
Relational Database Management System (RDBMS)
A relational database management system (RDBMS) is a database management
system (DBMS) that is based on the relational model as introduced by E. F. Codd,
of IBM's San Jose Research Laboratory. Most popular databases currently in use
are based on the relational database model.
Example: ORACLE, INGRESS, SYSBASE, Dbase 3+, DB2
50
7/30/2019 Ajay Practical File
51/62
SQL Introduction
SQL stands for Structured Query Language and can be pronounced as SQLor sequel (Structured English Query Language).
It is a query language used foraccessing and modifying information in thedatabase. IBM first developed SQL in 1970s. Also it is an ANSI/ISO standard. Ithas become a Standard Universal Language used by most of the relational databasemanagement systems (RDBMS). Some of the RDBMS systems are: Oracle,Microsoft SQL server, Sybase etc. Most of these have provided their ownimplementation thus enhancing its feature and making it a powerful tool.
Few of the sql commands used in sql programming are SELECT Statement,UPDATE Statement,INSERT INTOStatement, DELETEStatement,WHERE Clause, ORDER BY Clause, GROUP BY Clause, ORDER Clause,
Joins, Views, GROUP Functions, Indexes etc.
In a simple manner, SQL is a non-procedural, English-like language that processesdata in groups of records rather than one record at a time. Few functions of SQLare:
store data
modify data
retrieve data
modify data
delete data
create tables and other database objects
delete data
Types of SQL statements
There are three basic types of SQL statements:
Data definition language (DDL) statements
Data manipulation language (DML) statements Dynamic SQL statements
51
7/30/2019 Ajay Practical File
52/62
SQL Data Types
Every field or column in a table is given a data type when a table is defined. These
data types describe the kind of information which can be stored in a column.
Some of the common data types that we shall be using in this chapter are:
CHAR
VARCHAR2
NUMBER
DATE
LONG
CHAR(size)
A column defined with a CHAR data type is allowed to tore all types of characters
which include letters both uppercase and lowercase letters such as A,B, ..,Z, and
a, b, .., z, special characters like @ # $ %, etc and numerals that are perceived by
the system as letters.
VARCHAR2(size)
It is similar to CHAR but can store variable sized string having a maximum length
determined by size. Maximum value the size can have is 2000 characters.
NUMBER(p.s)
It is used to store variable length numeric data. The value ofp determines the total
number of digits possible to the left of decimal point. The second syllables,
determines the total number of digits possible to the right of decimal point.
52
7/30/2019 Ajay Practical File
53/62
DATE
This type of data is used to store date and time information. Default format is
YYYY-MM-DD.
LONG
LONG data type stores variable length character strings containing upto 2
gigabytes size. But use of LONG data type has got the following limitations:
A table cannot have more than one LONG type of data field.
It cannot be indexed.
It cannot be used with SQL functions.
It cannot appear in WHERE, GROUP BY, ORDER BY clauses.
53
7/30/2019 Ajay Practical File
54/62
Create a Table
Syntax:
CREATE TABLE
(,
,
.
.
.
);
Example:
Create table student
(Student_id number(2),
Student_Fname varchar (10),
Student_Lname varchar(10),
Student_address varchar(20),
Student_dob date);
54
7/30/2019 Ajay Practical File
55/62
Insert values into Table
Syntax:
Insert into values (, , .);
Example:
Insert into student values (01, raj, kapoor, delhi, to_date(04-dec-1987,dd-
mm-yyyy));
Retrieving Data from Table
Syntax:
Select * from
Retrieve some specific data.
Select from where
Example
55
7/30/2019 Ajay Practical File
56/62
Alter Table
To add a new column in table-
Syntax:
Alter table
Add
Example:
Alter table student
Add student_number varchar (20)
To drop a column from table
Syntax:
Alter table
DROP column
Example:
Alter table student
DROP column student_number ;
56
7/30/2019 Ajay Practical File
57/62
To change datatype-
Syntax:
Alter table
MODIFY column_name datatype;
Example:
Alter table student
DROP column student_number ;
57
7/30/2019 Ajay Practical File
58/62
Update Table
To change the content of column
Syntax-
UPDATE table_name
SET column1=value,column2=value2.. WHERE some_column=some_value
Example-
DELETE
Syntax:
DELETE from WHERE some_column=some_value
Example-
58
7/30/2019 Ajay Practical File
59/62
Desc TABLE
To display the structure of table
Syntax-
DESC table_name;
Example-
Desc student;
Drop Table
To remove or delete the table
Syntax:
DROP table table_name;
Example:
59
7/30/2019 Ajay Practical File
60/62
SQL Constraints
Constraints are used to limit the type of data that can go into a table.
Constraints can be specified when a table is created (with the CREATE TABLE
statement) or after the table is created (with the ALTER TABLE statement).
We will focus on the following constraints:
NOT NULL UNIQUE PRIMARY KEY FOREIGN KEY CHECK DEFAULT
SQL NOT NULL Constraint
The NOT NULL constraint enforces a column to NOT accept NULL values.
The NOT NULL constraint enforces a field to always contain a value. This meansthat you cannot insert a new record, or update a record without adding a value tothis field.
SQL UNIQUE Constraint
The UNIQUE constraint uniquely identifies each record in a database table.
The UNIQUE and PRIMARY KEY constraints both provide a guarantee foruniqueness for a column or set of columns.
60
7/30/2019 Ajay Practical File
61/62
SQL PRIMARY KEY Constraint
The PRIMARY KEY constraint uniquely identifies each record in a database table.
Primary keys must contain unique values.
A primary key column cannot contain NULL values.
Each table should have a primary key, and each table can have only ONE primarykey.
SQL FOREIGN KEY Constraint
A FOREIGN KEY in one table points to a PRIMARY KEY in another table.
Example:
Create table cust_orders
(
O_Id int PRIMARY KEY,
OrderNo int NOT NULL,
Cust_id varchar(20) REFERENCES customer(cust_id) );
61
7/30/2019 Ajay Practical File
62/62
SQL CHECK CONSTRAINT
A CHECKconstraint is used to control the values entered into a field.
Example:
Create table student_detail
(
RollNo varchar2(3) PRIMARY KEY,
Name varchar2(20) NOT NULL,
Age number(2) CHECK (Age > 18)
);
SQL DEFAULT CONSTRAINT
A DEFAULT constraint is used to assign default values to a column, before any
value is assigned to it.
Example:
Create table Employee
(
Emp_code Number(4) PRIMARY KEY,
Emp_name Varchar2(25) NOT NULL,
Desig char(10) NOT NULL,
Basic Number(6,2) DEFAULT 0
);