Transcripts
1. Introduction to SQL Course: Welcome to the beginner
course of complete Cule. In each class, we
are going to discuss the SQL from basics to advance. In basics, we are going to discuss about how to
create the table, how to display the table values, and how to insert the values. In the advance, we are going to discuss about the inner joins, outer join and other
joint conditions. And also we are going to discuss
the group bi conditions, order bi conditions, and other conditions we are going to discuss in the advance Cule. So this course is very, very, very useful for the students who are studying SQUL
for the first time. For that only, I'm
discussed the basics of SQUL to the advance of the SQUL. So let's see the course
2. Sql Class 1 : History Of Sql: First class. In today's class, we are going to discuss about the complete
introduction of the SQL. SQL stands for the
structured quarri language. So this language
is very used for the data retrieval
from the database. You can also use SQL to manipulate and change the
data in the database. And the second one
we are going to discuss is about the importance of SQL there are three
important of SQL. The first one is the
efficient data retrieval, and the second one is the data security and the
third one is the scalability. The first we are going to
discuss is the data retrieval. SQL enables quick and
efficient retrieval of data from the database. We can use the SQL to retrieve the data very fast
from the database. And the second one
is the security. Database security is very,
very, very important. So that's the
importance of the SQL. So SQL ensos the database
is more secured one. And the third one
is the scalability. The scalability is nothing, but we are going to provide the resources based on the
consumption of the consumers. That is the users. If the users want more data, we are going to provide them
more data for that user. If that user wants
lower amount of data, we are going to provide lower amount of
data for that user. That is the scalability. And the third we are
going to discuss is about the DDL DML and DCL
commands in the SQL. So the DDL stands for
data definition language. There are three
commands in the DDL. The first one is the create and the second one is the alter, and the third one is the drop. And the second is
the DML command. DML stands for data
manipulation language. So there are many
commands in the DML. The first one is the insert and the second one
is the update, and the third one is the dilate. And the third one is the DCL, DCL stands for data
control language. There are two
commands in the DCL. The first one is the grant and the second one
is the revoke. And the fourth topic we
are going to discuss is about advantages of the SQL. And the first one is
the data integrity. So there are many
constraint and rules for the SQL to provide
data integrity. Data integrity is nothing, but there will be no changes in the data which is
stored in the database. And the second one is
the transaxen control. So there are many transaxen
controls like acid property, the acid strands for
the A strands for the atomty and the C
stands for consistency, and the I stands for isolation and the D
stands for durability. So these are all the
transaxon control. And the third advantage is
that data independence. There will be no
data depending on other data to
perform their axons. And the last topic we
are going to discuss is about the SQL job opportunities. If you study SQL from
the basics to advance, you can have these
job opportunities. The first one is the
database administrator, and the second one is
the database analyst, and the third one is
the database developer. So if you master the SQL, you can have these job
opportunities. So that's it. In today's class, we
will discuss about the complete introduction
of the database language, that is the SQL. That is structured
query language.
3. Sql Class 2 : Create Table: And in today's class, we are
going to discuss about how to create our table
in the cle squal. For that, you have
to type the syntax for the creation of
table in the Aclsqud. For the first, you have
to type the create table. Name table name can be your own choice for that
our table name is students. After typing the table name, you have to type
the open brackets. Inside the open brackets, you have to type the
row heading values. For our table students, they have their own name, age, department, and course. These are the row
heading values. For that, we are going to type these row heading values
inside our table. For the first, we are going to type the role number
of the students. The role number must be
an integer data type. Also the role number is
init for each students. For that, I'm choosing the
role number as primary key. These primary key and faring key can be explained in
the upcoming classes. After typing the role number, we are going to type the
name of the students. For that, the name of the
students must be an data type. It must not be an
integer data type. Inside the bracket of the WCA, you can type any
number of values. After typing the name
of the students, we are going to type the row heating value
for the course. Course must be also
a CAR data type. Inside the brackets,
you can type any number of values up to 255. And then we are going to type the department of the students. So department is also
a CAR data type. At last, we are going to type
the age of the students. The age of the students must
be an integer data type. So age is integer data type. After typing all the
row heading values, you have to put close bracket and class with the semicolon. So this is the syntax for the creation of table
in the racLEcL. You can see in the first
row of our student table, the role number is
the primary key. These primary key and far in key can be explained in
the upcoming classes. In the second one, there
are many data types. The first one is
the WCR datatype and the second one is
the integer data type, and the third one is
the Boolean data type, and the fourth one is
the float data type, and the fifth one is
the binary datatype. So there are many other
datatypes in the SQL. The most, we are going to
use the VCR data type. After that, we are going
to run this SQL command. For that, you have to
select all the commands, and then you have to select
the run SQL statement. So you can see our table is
created in the SQL developer. So this is the format of creating the output in
the SQuL developer. After that, we are
going to create the second table,
the teacher's table. The first table is
the student table, and the second table
is the teacher table. For the same syntax for
the creation of the table. You have to type
the create table, and then the table name. The table name can be your own choice for that
our table name is teacher. And then you have to
type the open brackets. Inside the open brackets, you have to type the
row heading values. For the first, we are going to type the ID of the teachers. The ID must be an
integer data type. So it also unit you
for each teachers. For that only, it
is a primary key. And then we are going to type
the name of the teachers. The name must be VCR data type. So inside the brackets, you can type any number
of values up to 255. And then we are going to type the course that also
the R data type, and the department, it
also the WAR data type. At last, the age
of the teachers, the age must be an
integer data type. After typing all the
row heating values, you have to close the bracket and put semicolon at the end. After typing these commands, you have to run
this SQUL command. For that, you have to select all the commands and
select run SQL statement. So you can see the
second table is created, the teacher table is created. So this is the format
for creation of table in the Oracle escule.
So that's it. In today's class, we
discussed about how to create the tables in
the Oracle escule. In the upcoming class, we
are going to discuss about how to insert the values
in the created tables.
4. Sql Class 3 : Insert Values: Last class we
discussed about how to create the table
in the RCL scull. In today's class, we are
going to discuss about how to insert the values
in the created table. In the last class, we have
created the two tables, the student table and
the teacher's table. We are going to insert the values in the each
tables we have created. First, you have to
type the insert, and then you have to
type into Inset into. After that, you have to
type your table name. After that, you have to
type your table name, and then you have to type the values inset
into table values. So this is the syntax. And then you have to
type the open bracket. In that, you have to type
the values for the tables. The first one is the roll number and the second one is the name, and the third one is the course, and the fourth one
is the department, and the fifth one is the age. So you have to tie these
values inside the brackets. First, we are going to type the roll number that
is 100 and the second, we are going to type the name, and then you have to
type the course name. That is mass. And then you have to tie the
department name. So department can
be your own choice, whether it is CSE or EC
or E or IT or mechanics. And the last one is the He, so age of the students. And then you have to close the bracket and put
semicolon at the end. So this is the syntax for
creation of the values inset. So you have to tie
inset into students. The students is the stable name. And the values
inside the brackets, you have to type the
values of the tables. The first one is the roll number and the second one is the name, and the third one is the course, and the fourth one
is the department, and the fifth one is the age. After that, we are going to run this SQUL command for the
insert of values in our tables. For that, you have to
select this line only. So we have successfully inserted our values in the created table. After that, we are going to insert the values
for the five times. For that, you have to copy this line and paste
it as five times. After that, you have to change the values for each columns. For the first, we
are going to change the role number and the second, we are going to change
the name, and the third, we are going to change the
department, and the fourth, we are going to
change the course, and the last, we are going to change the age of the students. So you have to change
them for your own choice. You can type any number of
values or any number of names, coures or department
for your table. Changing the values, you
have to run this command again for the insertion
of values in our tables. For that, you have to select all the commands and
select run SQL command. So you can see there
are four rows are created for our table students. So we have to insert the values for the second
table that is teacher. For that, you have to
type the same command insert into the table
name that is the teacher. After that, you have
to type the values, and then you have to
type the open brackets. Inside the open brackets, you have to type
the column values. For the first, that is ID and
the second one is the name, and the third one is the course and the fourth one
is the department, and the fifth one is the H. You have to type one by one. After typing these
values, again, we are going to insert these
values for the five times, for that you have to copy this command and paste
it as five times. And then you have to
rename the values. After changing the values, you have to run this command. For that, you have to
select these commands only. So you can see there
are five rows are created for our table teachers. So that's in today's class, we discussed about how to insert our values in
the created tables. For that we are creating
the two tables, the students table and
the teacher's table.
5. Sql Class 4 : Select Command: Welcome, everyone.
In today's class, we are going to discuss
about the salt condition. So Salet is very,
very useful for displaying all the values
created in the table. For that, we are going to use the Salt command in our class. So let's get started. For that, we have to type
the salt star represents, it display all the values
created in the table. F which table you have to type the table name,
that is the students. So at last, you have to
select the semicolon. So this is the first
type the star represent, I displays all the values
created in the table. After typing that,
you have to select this command and select
run SQuL statement. So you can see all
the values created in the table students are displayed
in our STUL developer. The first one is the roll number and the second one
is the course, and the third one
is the department, and the fourth one is the age. So you can also see the values
for each rows and columns. So in the previous class, we are insert the
values in the tables. So these values are sewn
using the SeLT command. After that, we are
going to discuss the two commands
with the select. The first one is the distinct. The distinct removes the
duplicate values from the table. It sews only the one
time of the value and removes the repeton
of the same value. For that Oto tights select distinct so your column name, whether it is
department name, age, or ID or course, from the table name. The table must be
students or teachers. So it removes the duplicate
values from the course. If the course contains two or more same values,
it removes them. You have to select this
command and run this command. After that, you can see
the distinct course value from our students table. So in the students table, you can see the mass is
repetated or duplicated. For that, the distinct removes the mass value from our course. It shows only the one
time of that mass. After that, we are
going to discuss the second one that
is the unique values. So unique is same as
the distinct value. It also removes the duplicate
values from our table. Unique, so unique
is the keyword. You have to type your
course or department name or any other column name, and then you have to type the
from with the table name. So it removes the duplicate
values from our table. So it also same as
a distinct one. So we are going to select the unique department
from our teacher table. So in the teacher table values, you can see the
CSE is repetated. For that, the unique removes them and source
only the one time.
6. Sql Class 5 : AND OR NOT Command: Hello, everyone.
In today's class, we are going to discuss about
the and or not conditions. For that, you have
to type this syntax, select name course from the table name, that is the students
were condition, and then you have to type the age or any other conditions, age greater than 20. And roll number must
be equal to 100. So these two condition
must be satisfied for the displaying the values of names and codes from
the student table. So is based on both
condition must be satisfied. If the age equal to 20 and
the role number equal to 100, so these two conditions
must be satisfied. After that, only these
values are displayed. So if any one of the
condition is not satisfied, so the is not
displaying the values. So after that, you have
to run this command. So you can see the output value which is satisfy the condition. So in our students table, the age and role number
must be satisfied. The role number must be 100
and the age must be 20. For that, these two
conditions are satisfied. So we are going to display
the name and the course. For that, you can see the name and the course of the table. So this is the use
of the conditions. Both conditions
must be satisfied. So R condition is based on if any one of them is satisfied, it displays the values. And is based on both
conditions must be satisfied. R is based on if any one
of them is satisfied, you can display the values. If the A equal to 20 or
roll number equal to 100, if any one of them satisfied, it source the values. So you have to run this command. After that, you
can see the values displayed in the 12 developer. So you can see the first
row, the age is 20. For that, you can see
the name and the course. You can also see the
roll number is 100. Both conditions are satisfied. You can also see the name
and cos are displayed. In the second one, you
can see the age is 20. The one condition is satisfied. For that, you can see
the in row is displayed. After that, we are
going to display the third command that
is not condition. So not is based on displaying the values except the
naught condition. For that, you auto
type, select, name, course from student
table where condition, not Age equal to 20. We are going to display the name and course
from the student table, which the H must
not be equal to 20. So that is the
definition of the nut. The nut source, it
must not be displayed. If the H equal to 20, these name and course
must not be displayed. So it removes the not conditions and sows the other values. After that, you can
see the name and course displayed for
our knot conditions. So if the age equal to 20, these rows must not
be displayed for our table. So that's it. In today's class,
we are discussed about the three commands. That is the first
one is the and and the second one is the R
and the third one is the
7. Sql Class 6 : Min & Max Command : Come, everyone.
In today's class, we are going to discuss
about the two conditions, that is min and max conditions. In the previous class, we discussed about the
or not condition. For the min and max, it source the minimum value and the maximum value in our table. For that only, the
min and max are used. For that, you have to type this command for the
min and max conditions. The first one is the select. We are going to
display the values. And then you have to tie the men of the row or column name. For that, we are going to select a minimum age from our table. That is the students. So it sorts the minimum age
values in our table students. After that, you have
to run this command, so you can see the
minimum age value in our table students is 20. So in our inserted values, the 20 is the minimum value. For that only it sows the
minimum age that is 20. So other values are
greater than 20. After that, we are
going to discuss the maximum condition. Select max of age from student. So it shows the maximum age
value in the student table. So you have to run this command. So you can see the 25 is the maximum value in
the student table. Today's class, we are discussed about the min and
max conditions. The min max and conditions are very
useful for if you want to display the minimum values or maximum values
from the table, you can use that min
and max conditions.
8. Sql Class 7 : Alias Command: Hi, everyone. In today's class, we are going to discuss
about the As condition. As Cdison is very,
very useful for. If you want to change your own name as
your own convenient, you have to use
the AS condition. For that only, the AS
condition is very useful. We are going to type
the select command, and then we are going to use the aggregate function
that is min of H. And then you have
to tie the AST word. And then you have to tie the convenient name for the mean of H. So we are going to tie the minimum H. So the sky
word changes the men of g name to minimum H
for our own convenience. And then you have to type the from condition with the table. And then you have to type the
table name from table name. So the a changes the min
of g to the minimum age. After that, you have
to run the command. So you can see in the
output it sows minimum age. So the aS keyword changes the name min of g
to the minimum age. So the minimum age is 20
in our student table. So if you remove the ASK word
and then run the command, so you can see the men of H. So it goes through
the default name of the SQL developer. So that's it. In today's class we
discuss about the Akword. So ASK word is very, very useful for reining the default one to the convenient name
of your own choice.
9. Sql Class 8 : Like Command : One. In today's
class, we are going to discuss about the condition. In previous class, we
discussed about the order by having the group
by condition. We are going to display on one example for that,
you have to type, select name from students with the ware condition
where the name must be, so you have to time the name. So whether the name
start at Run it must be displayed in
our SQL statement. If the values in our table
starts with the name Run, it must be displayed
in our STL output. For that only, you can
use the lie condition. If the name starts like As, B, or any other RN g
or any other Kumar, or any other one, you can
use the lie condition. After that, you have
to run this command. So you can see there are only
one name starts with a Run. So you can see there are only one value which
starts with the Run. So we are going to see
the other example. So we are going to display the names started from the Bala. If the name started with Bala, it must be displayed. In that, you can see there are no names started with Bala. So in our table, you can see the name started with Bar Siva. There is no name
started with Bala. For that only, you can see the output display no
name started with Bala. If I type Bara Siva, it shows the output. Let's so you can see the
name started with Barlaseva. After that, we are going to display the wildcard conditions. For the wild card, you have
to type the percentage. If the name starts with the A, it must be displayed. For that only the percentage
is used in the wild card. So you how to type A percentage. A percentage means A
started in the table. So you have to
type A percentage. It shows that whether the
name started with the A, it must be displayed. You can see in the output, there are two names which are started with the alphabet A. If the percentage comes
before the alphabet, it shows that names ending with the alphabet
must be displayed. So there are two wild
cards with the percentage. If the alphabet comes
before the person dates, it shows the starting. If the alphabet comes
after the person dates, it shows the ending. So we are going to display the names which are
ending with the alphabet, so there is only one name which ended with the alphabet A. You can also see
the other example. We are going to display the name which are ending
with the alphabet. So there is only one name
which are ended with the alphabet N. After that, we are going to discuss
the naught like condition. For that, we are going
to discuss one example in that we are going to display the name from
the student table, which the name must
not be it Run. Except Run we are going
to display all the names. For that only, you can
use then condition. So you can see, except the RN, all the names are displayed. So that's it. In today's class, we are discussed
the two condition. The first one is the
light condition, and the second one is
the not light condition. In light condition, we
are discussed the 21, the percentage coming to the front and the percentage
coming to the last.
10. Sql Class 9 : Count Avg Sum: One. In today's class,
we are going to discuss about the
aggregate functions. So there are many other
aggregate functions in the SQL. The first one is
the min and max, we are discussed in
the previous class, and the second one is the count, and the third one is the average and the fourth one is the sum. The first, we are going
to discuss the count. For that, you have to type select and then you have to type the count
aggregate function. After that, you have to
type the open bracket. Inside the open bracket. Inside the square bracket, you have to type
the display values. For that, we are going
to type the age. After that, you have
to close the bracket and type from table name. So it source the count of
H from our student table. The count is very, very
useful for if you want to count number of values
present in your table, you have to use the count
aggregate function. For that, we are going
to count number of ages present in
our student table. So you can see the output five. It source number of counts
for the age is five. In the student table, we have inserted five age
values for our table. 20, 25, 24, 20, and 22. So there are five counts. For that only source five
for our count of age. So you can also use and son
with the aggregate functions. For that, you have to type, select count of age from the table name
with the condition, the condition must be
age greater than 20. So we are going to count the ages which are
greater than 20. You have to run this command, so you can see there
are three commands, so you can see the
count is three. So there are three ages
which are greater than 20. So you can see the 25 24 and 22, which are greater
than the age 20. So the output source
the count of three. After that, we are
going to discuss about the second
aggregate function that is average. Yeah. So how to type this form, select average of roll number. So we are going to
select the average of roll number from the table name, that is the students So this is the format
for the average. We are going to average the roll number from
the student table. After that, you have
to run the command. So you can see the average of the roll number is one n two. So you can see the middle
value is one n two. So average shows
the middle value. So in our student table, one n two is the
middle average value. After that, we are
going to discuss about the last aggregate
function that is sum. So for that, you have
to type this select sum of ID or any other roll number or any other one
from the table name. So it sums all the IDs
in the teacher table. Then you have to
run this command So the output source the
value thousand and ten. So you can see it sums all the ID values which are inserted in the teacher table. You can see the 200 plus 200
plus 200 plus 200 plus 200. It goes to the
thousand So that's it. In today's class,
we are discussed about a three
aggregate function. The first to is the count and the second one
is the average, and the third one is the sum.
11. Sql Class 10 : Order By Command: We are going to discuss about
the order by condition. Order by condition is
based on the two values. The first one is the
descending order and the second one is
the ascending order. So we are going to discuss
one of the examples for that, you have to tie, select. So we are going to select the name from the student table. After that, you have to
tie the order by keyword, and then we are going
to order the names from the ages for this
example source, we are going to select the
name based on the edges. So that's the useful of
the order by condition. We are going to order the
names based on the edges. The default order by
is the ascending der. For that, in our example, we are going to display the names based on
the ascending edges. So you can see all the names are displayed from our students based on the order by of
age in the ascending order. So in the student table, we insert the values
of the ages like 20, 25, 24, 20 and 22. So these names are based on the order of the ages
in the ascending order. After that, we are
going to discuss the second value that is
the descending order. For that, you have
to type, select, name, frame, the student table. After that, you have to type
the order by condition. We are going to order by ages
with the descending values. So in displace the name based on the order of the ages with
the descending values, that is large too small. So it is the opposite
of the ascending order. So in the upcoming class, we are going to discuss about
the group pipe condition.
12. Sql Class 11 : Group By Command: Welcome everyone.
In today's class, we are going to discuss about
the group by condition. So group by condition is used for the aggregate
functions like min, max, count, average sum. For that only, you can use
the group by conditions. For the group by condition, you have to type the syntax. For the first, we are going
to use the select condition, and then you have to type the aggregate functions
like min of H, count of H, max of H, any other aggregate functions, and then you have to type
the student table name. After that, you have to type the group by
condition keyword. So we are going to
group the values of minimum age with the name. So you have to run this command, so you can see the minimum of age based on the group by name. So if the name contains
the alphabetic order, it changes the age
according to the name. So in the student table,
the minimum age is 20. For that, you can see
the first value that is 20 is presented in our output. So that's it in today's class, we discussed about the
group Pi condition. So group B gradison is very useful for the
aggregate functions.
13. Sql Class 12 : Having Command: Everyone. In today's class, we are going to discuss
about the having condition. So having condition is
alternate to the W class. So we class is not used for
the aggregate functions. For that only, we
are going to use the having conditions for
the aggregate functions. So we are going to see an
example one so you have to type the select name from
the student's table. Having keyword, you have to
type the aggregate functions, whether it is Min
of H, max of H, count of H, sum of H, average of H. So we are going to type the Min of H with the condition
greater than 20. So it is same as the ware class, but we are going to use the having condition for
the aggregate functions. So we are going to select
the name from the students which are having the minimum
of age greater than 20. So you can also see in the previous class we have
used the were condition. So W is also same as we
age greater than 20, but it is not used for
the aggregate functions. For that only we are going
to use the having condition. Before running the
having condition, you have to type the
group by condition, which are discussed in
the previous class. So we have to type the
group by condition. After that, only you have to
type the having condition. In the previous class,
we are discussed the minimum of H
greater than 20, which are grouped by the name
of the alphabetic order. If the A comes first
with the minimum H, it sows in the first value. The first one AJ Kumar, that is 25, the
alphabet stars A. For that, it sows
in the first place. And the second one is the Mnoch, the manoch having
the wage of 22, which is greater than 20. For that, it sows
in the second one, and the third one is the ba CVA. The balus age is 24, which is greater than the 22. So that's it in today's class we discuss about the
having condition. Having is alternate to the war condition because it is used for
aggregate functions.
14. Sql Class 13 : Union Command: Today's class, we are going to discuss about the union command. If you want to combine
the two commands, you can use the union command. For that, we are going
to discuss an example. For that, we are
going to discuss an example with other
two selet commands. If the statements are
not equal or save, the union command
source the error. So after typing the
two statements, you have to run the command. So you can see the display sows the two commands
of the select. The first command is the
select star from the students. It displays all the
values from the student. And the second is the select
star from the teachers. So it displays all the
values in the teacher table. So you can see the union is used for combining
the two statements.
15. Sql Class 14 : Inner Join: Today's class, we're going to discuss about the
joint conditions. So there are many joint
conditions in SQL. But in our class,
we are going to discuss about the four
joint conditions. The first one is the inner join and the second one
is the left join, and the third one
is the right join, and the fourth one
is the full join. For the inner join, we are
going to create a two tables. We are going to match the common values
between both tables. For that, only we can
use the inner join. So we are going to select the first table that is the student table and
the column value, that is course, you have to
type student dot course. That is table name dot column. After that, we are
going to select the second table that is
teacher with the column name. That is course. After that, you have to type from the
first table that is students. Then you have to type
the inner join keyword and the second table name. And then you have to
type the on condition. After typing the on keyword, you have to type the column, which are matches
in the both table. For that only, you have to
type after the on keyword. You have to type the common
values between the tables. So this is the syntax for
the inner join condition. First, we are going to select the two values from each table, that is the select student dot
course teacher dot course. After that, you have to
tie the two table names that is from students
inner join teacher. And then you have to
type the keyword. After that, you have to type the common value matches
between both table. So in our example, the common value between
both table are department. After that, you
can see that there are two courses are created. That is student table course and the teacher table course, which are matches with
the common values, that is student department
and the teacher department. So in the values of the
students and the teacher, you can see the
signs and the mass. The first one is the signs and the second one is the mass. In the signs, you can see the CSE department this
matches with the second table, mass with the CSE department. So these two department
are matches with both. For that only, the sine course is matches with the mass course. So that's it. In today's class, we discussed about
the inner join. So inner join matches the common values
between the both table. So in the upcoming class, we are going to discuss about the left join and
the right join.
16. Sql Class 15 : Left Join & Right Join: And in today's
class, we are going to discuss about the two joints, that is the left join
and the right join. In the previous class, we
discussed about the inner join. So inner join matches the common values
between the both tables. For the first, we are going
to discuss the left join. In the left join, it matches the values which are
common in the left table. For that, you have to
type the selet command, and then you have to type the table name within
the column name. That is the table
name dot column name, and the second table name
with the column name. From the student table, left join, the second table, that is the teacher table. The student table
is the left table. Teacher table is
the right table, and then you have
to type on keyword. After that, you to type the common values
between each table. That is the department is
common between both tables. So we are going to
display the common values which are present in the left table that
is the student table. So that is the use
of the left join. So you can see the output is
displayed for the left gin. For the first, you can see
the sins and the mass. In the sins, you can see the
CSE department is common. In that student table
with the teacher table, the mass with the
CSE department. So there are two CSE
department which are common. For that only it sows
the sines and mass. So we can also see
the second row that is the mass and the mass. In the mass, you can see the CAE is common in the student table. And the second table
that is the teacher, it also contains the
mass and the CSE. For that only left joins and
source the display values. So after that, we are going to discuss about the right join. So in the right join, it matches the common
values in the right table. That is the teacher table. The student table
is the left table, and the teacher table
is the right table. So it commonly matches the values which are
present in the write table. So you have to change the
left join to the right join. Other commands are the
same as the left join. So you can see the
output results, so is the mass and the computer. So you can see the mass contains the CSE matches with
the computer CSE. So that's it. In today's class, we discussed about the two joins the left join
and the right in.
17. Sql Class 16 : Primary key: However, in today's class, we are going to discuss about
the primary key far in key, check constraint and
not null constraint. So these are the
constraints we are going to discuss
in today's class. First, we are going to discuss
about the primary key. So the primary key is
unique for the table. So it does not contain any duplicate values or any
other repetated values. It must be unique for that
in the table of the student, the role number is
unique for each student. For that only, the
role number is the primary key of
the table students. You can also see the name,
course, department, engage. These can be
duplicated or same for each students are same for
two or more or students. The name can be same
for two more students. For that only you cannot use the primary
key for the name. So you have to use
the primary key for the unique keyword. And the second, we are going to discuss about the far in key. Far in key is the reference
of the primary key. For example, if we
create two tables, the student table one and
the student table two, in the student table one, the role number is
the primary key. If you want to create
the primary key in the second table also, we can use the far in key. The far in key reference
as the primary key. So it also the same
as the primary key. Third one we are going to discuss is about the
check constraint. If you want to insert the values based on
some conditions, you can use the
check constraint. For that, in our table, we are going to use the check
constraint for the age. If the age must be
greater than 20, then only we are going
to insert the values. If the age less than the 20, we are not going to
insert the values. It is same as the
were condition. But the ware condition
is used in this select, but we are going to use the check constraint
in the table also. So it checks the age
greater than 20, then only it enters the values. If the age less than 20
is entered in that table, it shows the error. At last, we are going
to discuss about the last constraint
that is not null. So naught null is used for
if we enter any null values, it shows the error because we have used the
naught null constraint. So that the table must contains each row,
each column values. It must not be an empty
cell or empty null. So for that, only
not null is used.
18. Sql Class 17 : Alter Command: As we are going to discuss about the alter table condition. In the alter table, there are two conditions are available. The first one is the add and
the second one is the drop. We are going to discuss these
two condition one by one. For the first, we are going to discuss about the add
column condition. For that, you have to type the command alter
table, table name. After that, you have to
type the keyword add. If you want to add columns, extra columns for your table, you have to type this command. You have to type
your column name, that is the new column
name with the data type. For that, the gender
must be CR data type. After typing that, you
have to run this command. So you have to run this command so you can see the
student table is altered. If you display the student
table with the set command, you can see the new
column is added. If you want to
delete any columns, you have to type the
drop column command. For that, you have
to type alter table, the table name, and then you have to type the
keyword drop column. And then you have to
type the column name. For that, we are going to
delete the column gender. Then you have to run
the command so you can see the table is altered because the
column is deleted. After running the
select command, you can see the error is zoned because we are deleted
the column gender or that only sows the
error. So that's it. In today's class, we discussed the alter table command
with two conditions, add column and then
draft column condition.
19. Sql Class 18 : Drop Table: In today's class,
we are going to discuss about the
two conditions. The first one is the
drop table condition and the second one is the
truncate table condition. These two conditions is very, very important for the
interview of SQL cotins. You have to remember
which condition performs which axons. First, we are going to discuss
about the truncate table. So Truncate is very
useful for if you want to remove the
values insert the table, you can use the truncate table. Truncate removes all the
values inserted in our cable. For that, you have to type
truncate table table name. So it removes all the values
inserted in the table. So you have to run the command before running the command, we are going to display what are all the values
inserted in our table. So you can see these
are the values inserted in our table student. After that, we are going
to truncate this table. That is removing all the
values from this table. So you can see the student
table is truncated. Again, we are going to
display the student table. In that you can
see all the values inserted in our student
table are removed. So that is the use of
the truncate table. It removes only the values. After that, we are going to display the drop
table condition. So drop table is very
useful for if you want completely
remove the table, you can use the drop
table condition. So that is the difference between the truncate
and the drop. Truncate removes the values. Drop removes the complete table. If you run the Slet command
of the student table, you can see the error is
zoned because the error sows the table created because we deleted the table using
the drop table condition. So that is the use of the
drop table condition. So you must remember which
command performs which axon, Trant performs remove values. Drop performs delete table.