0% found this document useful (0 votes)
12 views

Anuj Dbms Ass 1

The document discusses SQL and provides examples of SQL data types, creating tables, and modifying table structures. It defines SQL, lists its features, and describes common data types. It also shows how to create tables, add/remove columns, and modify column properties.

Uploaded by

Poonam Jha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Anuj Dbms Ass 1

The document discusses SQL and provides examples of SQL data types, creating tables, and modifying table structures. It defines SQL, lists its features, and describes common data types. It also shows how to create tables, add/remove columns, and modify column properties.

Uploaded by

Poonam Jha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment 1

Q1. What is SQL? What are the various features of SQL?

Solution:

Structured Query Language

• SQL was developed by IBM in 1970s for use in System R, it is an ISO and ANSI standard.
• Structured Query Language (SQL) is a language that provides an interface to relational
database systems.
• SQL is a computer language for storing, manipulating and retrieving data stored in relational
database.
• All relational database management systems like MySQL, Oracle, Sybase, Informix, postgres
and SQL Server use SQL as standard database language.
Features of SQL

• SQL can be used by a range of users, including those with little or no programming
experience.
• It is non procedural language.
• It reduces the amount of time required for creating and maintaining database systems.
• It is English like language.

Q2. Describe various Data types used in SQL.

Solution:

SQL Data types

• DATE()
The date is displayed in YYYY-MM-DD format. This format is default for the DATE data type. The
DATE data type can store values from 0001-01-01 through 9999-12-31.

• CHAR(size)
CHAR is a fixed length string data type, so any remaining space in the field is padded with blanks.
CHAR takes up 1 byte per character. So, a CHAR(100) field (or variable) takes up 100 bytes on
disk, regardless of the string it holds.

• VARCHAR(size)
VARCHAR is a variable length data type, so it holds only the characters you assign to it. VARCHAR
takes up 1 byte per character, +2 bytes to hold length information. For example, if you set a
VARCHAR(100) data type=’Jen’, then it would take up 3 bytes (for J, E and N) plus 2 bytes, or 5
bytes in all.

• INTEGER
A 32-bit signed integer value. The range of INTEGER is -2147483648 to 2147483647. The int data
type is the primary integer data type in SQL server. The bigint data type is intended for use when
integer values might exceed the range that is supported by the int data type.

• NUMBER(p,s)
Number allows a decimal component whereas integer doesn’t. If you try to store 3.43 in an integer,
it will just store 3. Number allows for much larger values than integer does. p is a precision
value; s is a scale value.For e.g, number(6,2) is a number that has 4 digits before the decimal and
2 digits after the decimal.

Q3. Create table student with fields: Roll No. , Name, Course and Date of Birth and display its
structure.

Create table student123 (rollnonumber(10), name varchar(20), course varchar(30), dob date);

screenshot

Desc student123;

screenshot

Q4. Modify the structure of student table as follows(display structure after every modification):

a. Add two new columns named Section and Contact No.


Alter table student123add(section varchar(10), contactno number(10));
screenshot
Desc student123;
screenshot
b. Change the size of course column by 2 points.
Alter table student123modify(course varchar(32));
screenshot
Desc student123;
screenshot
c. Remove the column Date of Birth.
Alter table student123 drop column dob;
Or
Alter table student123 drop(dob);
screenshot
Desc student123;
screenshot

Q5. Create table Employee with fields: EmpID, EmpName, Designation and Date of Joining

Create table employee123 (eidnumber(10), enamevarchar(20), designation varchar(30), doj date);

screenshot

Desc employee123;

screenshot

Q6. Modify the structure of Employee table as follows(display structure after every modification):

a. Add a new column Salary.


Alter table employee123add(salary number(10));
screenshot
Desc emp;
screenshot
b. Change the size of Salary by 5 points and Name by 10 Points.
Alter table employee123modify(salary number(15));
screenshot
Alter table employee123modify(enamevarchar(30));
screenshot
Desc employee123;
screenshot
c. Remove the fields Designation and Date of Joining.
Alter table employee123drop(designation, doj);
screenshot
Desc employee123;
screenshot

You might also like