In this collection, there will be a bunch of questions with answers
This collection is useful for all Computer and Engineering Students
1
WEB
PROGRAMMING
SUBJECT
CODE:
35251
QCODE:
546
PART - A
(Each question carries 2 marks, Answer any FIVE questions, Q.No. 8 – Compulsory)
1.Define EDGE. What is its use?
EDGE (Enhanced Data for Global Evolution) an upgrade for GSM/GPRS networks that triples
data rates (speed) over standard GPRS.
EDGE is used automatically when both the phone and network support it. EDGE phones will
automatically revert to the slower GPRS standard when EDGE service is not available.
2.What is the use of <canvas> tag?
The HTML <canvas> element is used to draw graphics on a web page. The HTML <canvas>
element is used to draw graphics via JavaScript.
The <canvas> element is only a container for graphics. You must use JavaScript to actually draw
the graphics. Canvas has several methods for drawing paths, boxes, circles, text, and adding images.
3.What is the use of CSS? What are its types?
Cascading Style Sheets (CSS) provide easy and effective alternatives to specify various attributes
for the HTML tags. Using CSS, a number of style properties for a given HTML element can be specified
Types CSS.
External Style Sheet.
Internal Style Sheet.
Inline Style Sheet.
4.Define Live connect.
Java applet can communicate with Java script in a same HTML page through a technology called
Live Connect which is supported by all major web browsers.
5.Give the disadvantages of JSP.
Disadvantages of JSP
Java knowledge is necessary to use JSP effectively.
It is difficult to trace errors occurred in JSP pages.
Database connectivity is not as easy as it should be.
It needs servlet engine
6.What is use of taglib directive in JSP?
The JSP taglib directive is used to define a tag library that defines many tags. We use the Tag
Library Descriptor file to define the tags. In the custom tag section we will use this tag so it will be better
to learn it in custom tag.
Syntax
<%@ taglib uri="uriofthetaglibrary" prefix="java class filename" %>
7.What is JDBCODBC driver
JDBC drivers are used to open database connections and to interact with it by sending SQL or
database commands then receiving results with Java. JDBC Bridge is used to access ODBC drivers
installed on each client machine. ODBC requires configuring on your system a Data Source Name (DSN)
that represents the target database.
2
8.What is the use of <HR> tag and <BR> tag?
HR TAG
The <hr> tag defines a the break in an HTML page (e.g. a shift of topic).
The <hr> element is used to separate content (or define a change) in an HTML page.
BR TAG:
The <br> tag inserts a single line break.
The <br> tag is an empty tag which means that it has no end tag
PART –B
(Each question carries 3 marks, Answer any FIVE questions. Q.No 16 – Compulsory)
9.Explain the IP address and its version?
IP Addresses
Internet Protocol hierarchy contains several classes of IP Addresses to be used efficiently in
various situations as per the requirement of hosts per network. Broadly, the IPv4 Addressing system is
divided into five classes of IP Addresses. All the five classes are identified by the first octet of IP
Address.
Internet Corporation for Assigned Names and Numbers is responsible for assigning IP addresses.
Internet Protocol version 4
The Internet Protocol version 4 was designed to be allocated to approximately 4.3 billion
addresses. At the beginning of Internet this was considered a much wider address space for which there
was nothing to worry about.
The sudden growth in internet users and its wide spread use has exponentially increased the number of
devices which needs real and unique IP to be able to communicate. Gradually, an IPS is required by
almost every digital equipment which were made to ease human life, such as Mobile Phones, Cars and
other electronic devices. The number of devices (other than computers/routers) expanded the demand for
extra IP addresses, which were not considered earlier.
Private IPs
: Few blocks of IPs were declared for private use within a LAN so that the requirement for
public IP addresses can be reduced.
NAT
: Network address translation is a mechanism by which multiple PCs/hosts with private IP addresses
are enabled to access using one or few public IP addresses.
Unused Public IPs were reclaimed by RIRs.
Internet Protocol v6 (IPv6)
IETF (Internet Engineering Task Force) has redesigned IP addresses to mitigate the drawbacks of
IPv4. The new IP address is version 6 which is 128-bit address, by which every single inch of the earth
can be given millions of IP addresses.
Today majority of devices running on Internet are using IPv4 and it is not possible to shift them to IPv6 in
the coming days. There are mechanisms provided by IPv6, by which IPv4 and IPv6 can co-exist unless
the Internet entirely shifts to IPv6:
Dual IP Stack Tunneling (6to4 and 4to6) NAT Protocol Translation.
10.Explain the creation of frames in HTML.
Creating Frames
To use frames on a page we use <frameset> tag instead of <body> tag. The <frameset> tag
defines how to divide the window into frames. The rows attribute of <frameset> tag defines horizontal
frames and cols attribute defines vertical frames. Each frame is indicated by <frame> tag and it defines
which HTML document shall open into the frame.
Example
Following is the example to create three horizontal frames:
<!DOCTYPE html>
3
<html>
<head>
<title>HTML Frames</title>
</head> <frameset rows="10%,80%,10%">
<frame name="top" src="/html/top_frame.htm" />
<frame name="main" src="/html/main_frame.htm" />
<frame name="bottom" src="/html/bottom_frame.htm" /> <noframes>
<body> Your browser does not support frames. </body> </noframes>
</frameset> </html>
11.What is the function of alert boxes in javascript?
Alert boxes
An alert dialog box is mostly used to give a warning message to the users.
alert ( “messeage”)
Where
alert – function name
message – to be displayed
Example 1:
<html>
<body>
<button onclick="myFunction()">Try it</button>
<script> function myFunction() { alert("Hello! I am an alert box!"); } </script>
</body>
</html>
12.What are the scriptlets? Give example.
Scriptlets
In JSP, java code can be written inside the jsp page using the scriptlet tag.
Syntax
<% java source code %>
The scriplet contains any number of valid java language statements only. Any text, HTML tags or JSP
elements must be outside the scriplet.
Example :
<html>
<body>
<% System.out.print("welcome to jsp"); %>
</body>
</html>
13.Write a JSP program to convert entered text into upper case.
<html>
<body>
<%
String s=‖web programming‖;
String s1=s.toUpperCase();
Out.println(―converted uppercase text is :‖+s1);
%>
</body>
</html>
Output:
Converted uppercase text is: WEB PROGRAMMNG
4
14.Explain the text effects in CSS 3.
CSS3 – Text contains several extra features.
text-overflow
word-wrap
word-break
The most commonly used property in CSS3
Values Description
text-align-last Used to align the last line of the text
text-emphasis Used to emphasis text and color
text-overflow Used to determines how overflowed content that is not displayed is signaled to
users
word-break Used to break the line based on word
word-wrap
Used to break the line and wrap onto next line
15.Explain the session objects in JSP.
Session object
A session is defined as a series of related interaction between a single client and the server. A
session object is created on the server. It is an unique identifier and is called session id. This id is given to
the client for communicating with the server. If the user is accessing a site having more than one JSP or
servlet pages, the same session id is shared among all the page.
Method
Description
long getCreationTime
This method returns the time when the
session was created
string getId()
This method returns the unique identifier
assigned to the session.
long getLastAccessedTime()
This method returns the time when the
user sent a last request associated with
this session.
Void setMaxIn activeInterval(int interval)
This method is used to give the maximum
length of time in seconds that the servlet
engine keeps the session open if no user
requests have been made.
void setMaxInactiveInterval()
This method returns the maximum time
interval in seconds that the servlet engine
keeps this session open between client
requests.
boolean isNew(0)
This method returns true if a new session
was created, but client has not joined.
16.Explain packet switching.
Packet Switching
Short comings of message switching gave birth to an idea of packet switching. The entire
message is broken down into smaller chunks called packets. The switching information is added in the
header of each packet and transmitted independently.
It is easier for intermediate networking devices to store small size packets and they do not take
much resources either on carrier path or in the internal memory of switches.
5
Packet switching enhances line efficiency as packets from multiple applications can be multiplexed over
the carrier. The internet uses packet switching technique. Packet switching enables the user to
differentiate data streams based on priorities. Packets are stored and forwarded according to their priority
to provide quality of service.
PART –C
(Each question carries marks, Answer division (a) or division (b))
17.(a)Explain the working of ISDN connection in detail with diagram. [10]
ISDN
ISDN is acronym of Integrated Services Digital Network. It establishes the connection
using the phone lines which carry digital signals instead of analog signals.
There are two techniques to deliver ISDN services:
1. Basic Rate Interface (BRI)
2. Primary Rate Interface (PRI)
The BRI ISDN consists of three distinct channels on a single ISDN line: t1o 64kbps B (Bearer)
channel and one 16kbps D (Delta or Data) channels.
The PRI ISDN consists of 23 B channels and one D channels with both have operating capacity
of 64kbps individually making a total transmission rate of 1.54Mbps.
The following diagram shows accessing internet using ISDN connection:
ISDN Advantages
The basic advantage of ISDN is to facilitate the user with multiple digital channels. These
channels can operate concurrently through the same one copper wire pair.
The digital signals broadcasting transversely the telephone lines.
ISDN provides high data rate because of digital scheme which is 56kbps.
ISDN network lines are able to switch manifold devices on the single line such as faxes, computers, cash
registers credit cards readers, and many other devices. These all devices can work together and directly be
connected to a single line.
ISDN takes only 2 seconds to launch a connection while other modems take 30 to 60 second for
establishment.
6
ISDN Disadvantages
The disadvantage of ISDN lines is that it is very costly than the other typical telephone system.
ISDN requires specialized digital devices just like Telephone Company.
(
OR
)
17.(b) (i). Explain the working of image tag with example.[5]
Insert Image
We can insert any image in your web page by using
<img>
tag. Following is the simple syntax to
use this tag.
<imgsrc="Image URL" ... attributes-list/>
The <img> tag is an empty tag, which means that it can contain only list of attributes and it has
no closing tag.
Example
To try following example, let's keep our HTML file test.htm and image file test.png in the same
directory:
<!DOCTYPE html>
<html>
<head>
<title>Using Image in Webpage</title>
</head>
<body>
<p>Simple Image Insert</p>
<imgsrc="/html/images/test.png"alt="Test Image"/>
</body>
</html>
17(b) (ii). Explain about web server and web browser.[5]
Web server
Web server is a computer where the web content is stored. Basically web server is used to host
the web sites but there exists other web servers also such as gaming, storage, FTP, email etc.
Web site is collection of web pages while web server is a software that respond to the request for web
resources.
Web Server Working
Web server respond to the client request in either of the following two ways:
Sending the file to the client associated with the requested URL.
Generating response by invoking a script and communicating with database
Key Points
When client sends request for a web page, the web server search for the requested page if
requested page is found then it will send it to client with an HTTP response.
If the requested web page is not found, web server will the send an HTTP response:Error 404 Not
found.
If client has requested for some other resources then the web server will contact to the application
server and data store to construct the HTTP response.
Web Browser
Web Browser is an application software that allows us to view and explore information on the
web. User can request for any web page by just entering a URL into address bar.Web browser can show
text, audio, video, animation and more. It is the responsibility of a web browser to interpret text and
commands contained in the web page.
7
Earlier the web browsers were text-based while now a days graphical-based or voice- based web
browsers are also available. Following are the most common web browser available today:
Browser Vendor Internet Explorer Microsoft Google Chrome Google Mozilla Firefox Mozilla Netscape
Navigator Netscape Communications Corp. Opera Opera Software Safari Apple Sea Monkey Mozilla
Foundation K-meleon K-meleon
Architecture
There are a lot of web browsers available in the market. All of them interpret and display
information on the screen however their capabilities and structure varies depending upon implementation.
But the most basic component that all web browsers must exhibit is listed below:
Controller/Dispatcher Interpreter Client Programs
Controller works as a control unit in CPU. It takes input from the keyboard or mouse, interpret it
and make other services to work on the basis of input it receives.
Interpreter receives the information from the controller and executes the instruction line by line.
Some interpreters are mandatory while some are optional For example, HTML interpreter
program is mandatory and java interpreter is optional.
Client Program describes the specific protocol that will be used to access a particular service. Following
are the client programs that are commonly used:
HTTP
SMTP
FTP
NNTP
POP
18. (a) Explain the creation of tables in detail [10]
The HTML tables allow web authors to arrange data like text, images, links, other tables, etc. into
rows and columns of cells.
tr and td Tags
The HTML tables are created using the
<table>
tag in which the
<tr>
tag is used to create table
rows and
<td>
tag is used to create data cells.
Here
border
is an attribute of <table> tag and it is used to put a border across all the cells. If you
do not need a border then you can use border="0".
Table Heading
Table heading can be defined using
<th>
tag. This tag will be put to replace <td> tag, which is
used to represent actual data cell. Normally you will put your top row as table heading as shown below,
otherwise you can use <th> element in any row.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Header</title>
</head>
<body>
<table border="1">
<tr>
<th>Name</th>
8
<th>Salary</th>
</tr>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
</tr>
</table>
</body>
</html>
This will produce following result:
Name
Salary
Ramesh Raman
5000
Shabbir Hussein
7000
Cellpadding and Cellspacing Attributes
There are two attribiutes called
cellpadding
and
cellspacing
which you will use to adjust the
white space in your table cells. The cellspacing attribute defines the width of the border, while
cellpadding represents the distance between cell borders and the content within a cell.
Colspan and Rowspan Attributes
You will use
colspan
attribute if you want to merge two or more columns into a single column.
Similar way you will use
rowspan
if you want to merge two or more rows.
Tables Backgrounds
We can set table background using one of the following two ways:
bgcolor
attribute - You can set background color for whole table or just for one cell.
background
attribute - You can set background image for whole table or just for one
cell.
Table Header, Body, and Footer
Tables can be divided into three portions: a header, a body, and a foot. The head and foot
are rather similar to headers and footers in a word-processed document that remain the same for
every page, while the body is the main content holder of the table.
The three elements for separating the head, body, and foot of a table are:
<thead>- to create a separate table header.
<tbody> - to indicate the main body of the table.
<tfoot>- to create a separate table footer
A table may contain several <tbody> elements to indicate different
pages
or groups of data. But it
is notable that <thead> and <tfoot> tags should appear before <tbody>
(OR)
18.b (i)
Explain various forms of INPUT tag with example.[5]
Single-line text input controls
- This control is used for items that require only one line of user input,
such as search boxes or names. They are created using HTML <input> tag.
Example
9
<!DOCTYPE html>
<html>
<head>
<title>Text Input Control</title>
</head> <body>
<form > First name: <input type="text" name="first_name" /> <br> Last name: <input type="text"
name="last_name" /> </form>
</body>
</html>
Password input controls
- This is also a single-line text input but it masks the character as soon as a user
enters it. They are also created using HTMl <input> tag.
Example
<!DOCTYPE html>
<html>
<head>
<title>Password Input Control</title>
</head> <body>
<form > User ID : <input type="text" name="user_id" /><br> Password: <input type="password"
name="password" />
s </form>
</body>
</html>
Multi-line text input controls
- This is used when the user is required to give details that may be longer
than a single sentence. Multi-line input controls are created using HTML <textarea> tag.
Example
<!DOCTYPE html>
<html>
<head>
<title>Multiple-Line Input Control</title>
</head>
<body>
<form> Description : <br /> <textarea rows="5" cols="50" name="description"> Enter description here...
</textarea>
</form>
</body>
</html>
18.(b). (ii). Explain about <svg> tag and its uses.[5]
<svg> element
SVG stands for Scalable Vector Graphics SVG is used to define graphics for the Web <svg> tag
Html5 introduce new tag <svg>, SVG stands for Scalable Vector Graphics. It is used to define graphics
for the Web. <svg> tag is container for SVG graphics.
SVG has several methods for drawing paths, boxes, circles, text, and graphic images.
It is mostly used for vector type diagrams like pie charts, 2-Dimensional graphs in an X,Y coordinate
system etc.
SVG Circle
Example
<!DOCTYPE html>
<html>
<body> <svg width="100" height="100">
10
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</svg>
</body>
</html>
19.(a).What are the image maps? Explain its types with example.[10]
Image maps
The <map> tag is used to define a client-side image-map. An image-map is an image with
clickable areas in the image, which has a link associated with it. There are two types of image maps. They
are,
i) Client side image map
ii) server side image map
i) Client side image map
With a client side image map, specify a list of areas that will be used as the links. The information
required to run the image map must be given in our html document. Since all the
Read Write information regarding the map functions are provided on the client side, it„s called client side
image map.
There are four types of these areas; rectangles, circles, polygons and default. Its down with the
help of <MAP> tag
Syntax
<map name=‖name of the map‖>
<area shape=‖name of the shape‖ cords=‖x,y,w,h‖
href=‖name of the link‖ alt=‖image‖>
</map>
Where
Name - name of the map used
Cords - x,y co-ordinates to fix the map area,
w- width of the map,
h-height of map area.
Shape - shape to be defined.
It can be rect, circle, poly
Href - url to be linked by this area
Alt - alternate message to display on the screen
Example
<html>
<body>
<img src="d:\planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap"> <map
name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="d:\sun.html">
<area shape="circle" coords="90,58,3" alt="Mercury" href="d:\mercury.html">
<area shape="circle" coords="124,58,8" alt="Venus" href="d:\venus.html">
</map>
</body>
</html>
11
ii)Server side image map
Server side image map is an image map run by common gateway interface. simply put the image
inside a hyper link and use ismap attribute which makes it special image and when the user clicks some
place within the image, the browser passes the coordinates of the mouse pointer along with the URL
specified in the <a> tag to the web server.
The server uses the mouse-pointer coordinates to determine which document to deliver back to the
browser.
<a href=‖url address‖>
<img src=‖peacock.jpg‖ width=‖200‖
height=‖250‖is map>
</a>
The coordinates of the mouse position are screen pixels counted from the upper-left corner of the image,
beginning with (0,0).
Example
<html>
<body>
<a href="f/cse.jpg " target="_self">
<img ismap src="d/images/logo.png" alt="Tutorials Point" border="0"/>
</a>
</body>
</html>
(OR)
19.(b). (i) Explain about cookies.[5]
Cookies
Cookies are information , stored in a small files on our browser. It contains some data.
1. A name-value pair containing the actual data
2. An expiry date after which it is no longer valid
3. The domain and path of the server it should be sent to
When a user visit a web page, his username stored in a cookie. Next time user visit a web page ,
the cookie just remember his username
Cookies contains the following components.
i) name -Cookies are set and retrieved in the form of key-value pairs
ii) expires -The date the cookie will expire. If this is blank, the cookie will expire when the visitor
quits the browser.
iii) Domain − The domain name of your site.
iv) Path − The path to the directory or web page that set the cookie
v) Secure − If this field contains the word "secure", then the cookie may only be retrieved with a
secure server. If this field is blank, no such restriction exists.
vi) Name=Value − Cookies are set and retrieved in the form of key-value pairs
Use of cookies
1. Web servers to perform functions such as tracking information about user visits to websites.
2. it is used to store information between web pages
3. The main use of the cookie is to identify the user and customize web page for them according
to the information stored in the cookie
19.
(b) (ii) Array objects in javaScript
.[5]
An array object stores multiple values in a single variable. An array is used to store a collection of
data, but it is often more useful to think of an array as a collection of variables of the same type.
Syntax
12
var arrayname = new Array(size);
Where
var, new - keyword
arrayname - user defined name
size - size of the array
Assigning values to the created array
This is use to giving initial values to the created array is called assigning values.
Syntax
arrayname(index) =‖value‖;
Example
var fruits = new array( "banana", "orange", "grapes" );
Methods in array object
i) length() – this method is used to find the number of elements in an array
ii) concat()-Returns a new array comprised of this array joined with other array(s).
iii)filter() - Creates a new array with all of the elements of this array for which the
provided filtering function returns true.
iv) join()-Joins all elements of an array into a string.
v) foreach()-Calls a function for each element in an array.
vi) reverse() – It is used to reverse the order of elements in an array.
vii) shift() - Removes the first element from an array and returns that element.
viii) sort()-Sorts the elements of an array
20.(a) What are the implicit objects? Explain request and session object[10]
Implicit Objects
Implicit objects created by the web container. These objects are used to create JSP pages. The users
need not to declare these objects, but they are provided by the container in the implementation class.
All the implicit objects are available only to scriplets and expressions only. The following are the
implicit objects.
Request Object
Response Object
Page context Object
Session Object
Application Object
Out Object
Page Object
Config Object
Exception Object
Request Object
The request object is an instance of a javax.servlet.http.HttpServletRequest object. Each time a
client requests a page the JSP engine creates a new object to represent that request.
The request object provides methods to get HTTP header information including form data, cookies,
HTTP methods etc.
Session object
A session is defined as a series of related interaction between a single client and the server. A
session object is created on the server. It is an unique identifier and is called session id. This id is given to
the client for communicating with the server. If the user is accessing a site having more than one JSP or
servlet pages, the same session id is shared among all the page.
20.(b).(i) Explain the JSP architecture.[5]
The web server needs a JSP engine ie. container to process JSP pages. The JSP container is
responsible for intercepting requests for JSP pages.
13
A JSP container works with the Web server to provide the runtime environment and other
services a JSP needs
A typical request / response phase of a JSP is defined below
a) Request is initiated for a jsp file by client using browser
b) Webs server (JSP engine) loads the JSP file and translate the JSP file into a java code . The Generated
Java code will be a Servlet.
c) Once Servlet (Java code ) is generated, JSP engine compiles the servlet. Any compilation errors will be
detected in this phase.
d) Now servlet class is loaded by the container and executes it.
e) JSP Engine sends the response back to client.
Translation and compilation phase is done only when
a) First request came for the jsp file
b) The generated servlet is older than the JSP file. This is the case when JSP file is modified
20.(b)(ii) Discuss JSP vs JavaScript.[5]
JSP versus java script
Sno.
JSP
Java script
1
It is executed by the server which
hosts the site
It is executed by the browser on our
local machine.
2
It is server side scripting which
enables us to write code in java and
do perform database interaction etc.
It is client side scripting language
which is used to interact with the
client at front end ie browser.
3
JSP uses full java technology
Java script uses little java technology
21.(a). Explain about crating connection and statement with operations in MySQL in detail. [10]
Creating connection
Database can be accessed only after creating connection object. Before creating connection a
driver must be loaded and registered.
The general function used to create connection is
getConnection()
DriverManager provides three methods for creating connections:
getConnection(String url)
getConnection(String url, String userID, String password)
getConnection(String url, Properties prop)
The driver manager maintains a list of registered drivers. When its getConnection() method is
invoked, it checks each driver whether it will accept the specified URL. The driver manager do this by
calling the driver„s connect() method, which returns null if the driver cannot accept the URL or an active
Connection object if it accept the URL.
Creating statement
14
The SQL language consists of statements that create, manipulate, and extract data from a
relational database. JDBC provides an object-oriented representation of these SQL statements. This
representation is called the java.sql.Statement interface. Statement objects send SQL commands to a
database, which can be any of the following types:
A data definition command such as CREATE TABLE or CREATE INDEX
A data manipulation command such as INSERT or UPDATE
A SELECT statement for performing a query
Data manipulation commands return a count of the number of rows modified, whereas a SELECT
statement returns a set of rows known as a result set.
The Statement interface has two specialized sub interfaces:
Prepared Statement - It uses precompiles SQL Callable Statement -It invokes stored procedures.
Statement
The basic interface for creating a statement is java.sql.Statement. It is obtained from the
connection object with Connection.createStatement().
Example:
Connection con = null;
try {
con = DriverManager.getConnection(URL);
Statement stmt = con.createStatement();
...
stmt.close();
}
finally {
if (con != null)
con.close();
}
Once a statement is created, it can be used to execute commands. The following four methods are used to
execute commands
executeUpdate
executeQuery
execute executeBatch.
21.(b)(i). Write a JSP program to find the maximum of the given numbers.[5]
<html>
<body>
<%
int a=40,b=27,c=80;
if(a>b)
{
if(a>c)
out.println(―BIG=‖+a);
else
out.println(―BIG=‖+c);
}
else
{
if(b>C)
out.println(―BIG=‖+b);
else
out.println(―BIG=‖+c);
15
}
%>
</body>
</html>
Output:
BIG=80
21.(b)(ii) How will you create a table in MySQL? Give the example and explain.[5]
The CREATE TABLE statement is used to create a table in MySQL.
The table creation command requires:
Name of the table
Names of fields
Definitions for each field
Syntax
Create table table_name (column1 datatype, column2 datatype, column3 datatype,…);
The following example creates a table called "student" that contains four columns: name, regno, dept and
year:
Example
Create table student(name char(15), trgno number(5), dept char(25), year number(4));
Creating Records
The INSERT INTO statement is used to create new records in a table.
It is possible to write the INSERT INTO statement in two ways.
First method
The first way specifies both the column names and the values to be inserted. In this method, values for all
columns are need not to be given.
syntax
INSERT INTO tablename (column1, column2, column3) VALUES (value1, value2, value3);
Example:
INSERT INTO student (name, regno, dept) VALUES ('raja', 1542, 'EEE');
Here, out of four columns, only 3 values are given.
Second method:
In the second method, column names are not mentioned, but values for all columns should be given.
syntax
INSERT INTO table_name VALUES (value1, value2, value3, ...);
Example:
INSERT INTO student VALUES ('raja', 1542, 'EEE', 2016);
Here, values for all columns are given.
KEY PREPARED BY
V. LAVANYA
Part Time / Guest Lecturer
120, Government Polytechnic College,
Purasaiwakkam, Chennai – 12.