0% found this document useful (0 votes)
55 views6 pages

Theory SQL

Uploaded by

shazakhalid14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views6 pages

Theory SQL

Uploaded by

shazakhalid14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

 LIKE clause is used for pattern matching.

(% stands for 0 or more charecters)


(_ stands for 1 character)
(% and _ together is taken as wild card charecters)
 Distinct clause is used to display data without
duplicates/repetition.
 ORDERBY clause is used to arrange data in ascending or
descending .
 GROUPBY Clause group the rows bases on similarity in the columns.
 WHERE Clause is used to retrieve data that meet specific
conditions
 IN operator it compares a value with set of values and
returns true if the value belongs in that set.
 CHAR: Fixed length string (It is a datatype)
Remaining spaces will be right padded with space.
 VARCHAR: Variable length string
Remaining space will be used.
 CROSS JOIN or Cartesian JOIN: The rows of two tables will be
combined to form cross join.
(QUERY: SELECT*from Supplier,Consumer;)
 EQUI JOIN: It will return the result set based on condition
Method1: SELECT*from Products,Customer where
[Link]=[Link];
Method2: SELECT* from product JOIN Customer ON
[Link]=[Link]
 Natural JOIN: Same as equi join but duplicate columns will not be
there in the result set
 (QUERY: SELECT*from product natural join Customers;)
 NOT NULL
Ensures that a column cannot have NULL values where
NULL means missing/ unknown/not applicable value.
 UNIQUE
Ensures that all the values in a column are distinct/unique
 DEFAULT
A default value specified for the column if no value is
provided
 FOREIGN KEY
The column which refers to value of an attribute defined
as primary key in another table.
--Foreign Key
It is used to set relationship between two tables.
It is the Primary key of some other table.
Every value from the foreign key should be from primary
key. This is called Referential Intergrety.
 Constraints are rules and regulations set on a table.
PRIMARY KEY CANDIDATE KEY
It is a unique key that can identify a It is also a unique key that will
table uniquely. A table can have identify a table uniquely. A table
only one primary key can have multiple candidate keys
Primary key column value cannot It will have null value
be null
Primary key is a candidate key It may not be primary key all the
time.
 Describe or desc clause is used to display table structure.
 Column name, datatype and constraints together are
called structure of table.
IMPORTANT FUNCTIONS THEORY
 Arguments are values passed through the function call.
 Parameters are values received at function header.
 Void function are functions that does not return any
value. Return value will be none.
 Fruitful functions that is returning any value.
 Positional Arguments
-Arguments are passed based on position.
-First Argument is given to first parameter.
-Second Argument is given to second parameter and so on.
-It should come before default parameters.
 Default parameters
If we are not passing any values from the function call
default values will be taken for parameter
 Keyword/Named Arguments
Names will be give for the values being passed in the
function call is known as named arguments.
The biggest benefit of keyword argument is we need not
remember the position of argument
seek() tell()
Will move the file pointer to the Will return the file pointer
desired position. position.

Eg:
(i) f. seek (2,0)
(from beginning to position)
(i) f . seek ( 6,1)
more the file pointer 6 places from the current file pointer
f. seek (-7,2)
It will move filepointer backward 7 position from end of file
(iv) f. seek()
The default value of reference point is zero.
TEXT FILE BINARY FILE
Text file stores information in Binary Files are used to store
ASCIl characters. binary data such as images
,audio, video and text.
Each line of text is terminated There is no delimiter in Binary
with a special character known File.
as EOL (End of Line)
Text files are easy to Binary file are difficult to
understand because these files understand.
are in human readable form
They are slower than binary They are faster and easier for a
files program to read and write
then textfiles.
Text flies are having Binary files are having
[Link] [Link]

 CRLF: Carriage Return Line Feed

Advantages of using ‘with’ statement


- It automatically closes the file
- It handles all the exceptions

!! Method 1 of opening a text file:


File Object=open(<filename>) OR File Object=open(<filename><mode>)

!! Method 2 of opening textfile:


with open (filename,mode) as filehandle:
→ Closing the file
SYNTAX
filepointer. close()
It will break the link between the file and the memory or
Resources.

→ Write (string)
write() method takes the string and wites it in a file.
For storing data with EOL character we have to add \n' at the end of the
string.
For storing numerical value we either convert it into sting using STR or
write in quotes.
→ Writelines (sequence)
writelines() methodis used to write sequence data types in a
file handle>.readlines()

You might also like