Creating a table, PL-SQL Programming

Assignment Help:

Creating a Table

Syantax:

CREATE TABLE ENROLMENT

(StudentId SID,

Name   VARCHAR (30) NOT NULL,

CourseId CID,

PRIMARY KEY (StudentId, CourseId)) ;

Explanation:

  1. CREATE TABLE ENROLMENT announces that what follows defines a variable in the database, named ENROLMENT. A variable in an SQL database is necessarily a table variable, just as in a relational database every variable is a relation variable. SQL does not use the term variable, instead referring to the variable as a base table (its value being called a table, of course).
  2. StudentId SID defines the first column of ENROLMENT, giving its name and either its declared type (a user-defined type) or its domain-we cannot tell which. If SID is a domain, then the definition of that domain specifies the declared type of the column StudentId. Similarly, Name VARCHAR(30) and CourseId CID define the second and third columns of ENROLMENT, respectively. A system-defined type is explicitly given for the column Name but the remarks on the declared type of StudentId apply in similar fashion to CourseId. Note carefully that in SQL it is correct, in ordinary prose, to identify columns by their ordinal position. By contrast there is no such thing as "the first attribute" of a relation or a relation variable.
  3. NOT NULL, appended to the definition of Name, specifies a constraint to the effect that the table assigned to ENROLMENT cannot contain a row in which "the null value of type VARCHAR(30)" appears for that column. The constraint is needed for accurate emulation of Example 2.6 in the theory book because relational theory does not admit any counterpart of SQL's NULL (so nor does Tutorial D). See the next bullet for an explanation of why NOT NULL is not appended to the other two column definitions.
  4. PRIMARY KEY ( StudentId, CourseId ) specifies that at no time can two distinct rows appear in the current value of ENROLMENT having the same value for StudentId and also the same value for CourseId. In enterprise terms, no two enrolments can involve the same student and the same course. In addition, it implies that the NOT NULL constraint applies to each those two columns.

Related Discussions:- Creating a table

Procedure, 1. Create a procedure called TAX_COST_SP to accomplish the tax c...

1. Create a procedure called TAX_COST_SP to accomplish the tax calculation task. Keep in mind that the state and subtotal values are inputs into the procedure and the procedure is

Change sql file into csv for product registration, Change Sql file into CSV...

Change Sql file into CSV for product registration on Magento Project Description: I have a set of files that are in Sql format and could like for a developer to help me with

Oracle 9i features, Bitmap Join Indexes - This feature will increase th...

Bitmap Join Indexes - This feature will increase the performance and detains the size and format of your databases in data Character Semantics and Globalization -This featur

Data types in sql - character, Data Types in SQL - Character CHARACTER...

Data Types in SQL - Character CHARACTER or, synonymously, CHAR, for character strings. When this type is to be the declared type of something (e.g., a column), the permissible

Difference between 9i & 10g, Difference between 9i & 10G When Oracle r...

Difference between 9i & 10G When Oracle releases any new databases then it are having some discrepancy with them. But 10G is having much difference than oracle 9i has. Oracle

How bulk bind helps improvement in performance?, How Bulk Binds Improve Per...

How Bulk Binds Improve Performance The assigning of values to the PL/SQL variables in SQL statements is known as binding. The binding of the whole collection at once is know

Declaring objects in pl/sql, Declaring Objects: You can use the object ...

Declaring Objects: You can use the object types wherever built-in types like CHAR or NUMBER can be used. In the block below, you can declare object r of type Rational. Then, yo

Assignment of variable - updating a variable, Assignment of Variable - Upda...

Assignment of Variable - Updating a Variable Syntax: SET SN = SID ('S2'); This can obviously be read as "set the variable SN to be equal in value to SID ( 'S2' )".

Albeit simple method , Albeit simple method : These all the truth tabl...

Albeit simple method : These all the truth tables give us our first as albeit simple method for proving a theorem: where check whether it can be written in propositional logic

Write an anonymous block that contains a pl/sql function, a. Write an anon...

a. Write an anonymous block that contains a PL/SQL function. Given an order number orderNo, the function will calculate the total number of the parts in the order. Then the anonym

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd