SQL Bhaskar Sir
SQL Bhaskar Sir
Oracle, SQL Server (1989), MySQL, Tera Data, DB2, Nateeza, PostGre, SQL
We can install SQL 50 times on a single computer so that we don't need to set up separate
hardware for each client, we can manage 50 clients with a single machine.
In 50 Instances first one is called as Default Instance and the remaining 49 will be called as
Named Instances. Default Instance will be having Windows Name.
1 Computer 50 Instances
*if
we
take 10 as limit and go with the char we have space according to the inputs in other hand varchar
will ignore the extra space and continue to the next inputs.
So we can observe wastage of space in char but we have to update any input it will be the difficult to
do the changes in varchar because of no space left so that it will change the placements of each and
every input in the table while in char we can make update the inputs without disturbing the other
placements.
*If we have Fixed length data will use Binary which is up to 8kb.(each media)
*If we do not have Fixed length data can use VarBinary which is from 1kb to 2GB.(each media)
*If we are maintaining the same data in two different servers and we need to update the changes in
server 2 accordingly for this we need to maintain the TimeStamp data type so that it will give us
some random numbering for the data we given and it will change is whenever the data got updated
in server1, so that we can easily make the same updates or changes in the server 2.
*Let’s assume Microsoft and IBM are merging and so they need to merge their employees data
together so in this case GUI generates some unique id to each and every emp so that no emp id will
be mix-up.
**Extra
table will
be called
as “BRIDGE
TABLE”
09 SQL Server - FKs, Cascade Features, Check Constraints, Identity
**Technical person has no idea about how the tables will link we need get this information
from the client or domain person to know the link b/w the tables simply we need to
understand the business to know about the relationship’s b/w the tables**
Can I have duplicate values in FK?
YES
Can I have null values in FK?
YES
Can I have null values in PK?
NO
Can I have null values in PK?
Yes(Only one value per Col)
How many FK’s per table?
Many
How many PK’s per table?
One
How many UK’s per table?
Many
What is self-Referential table?
A FK is referring its own tables PK, Then the table is called as self-Referential table.
Identity Property
Identity will have two strains one is SEED another one is Increment/Decrement
In the above ex we can observe that EID autogenerated with the help of Identity feature. Seed
starts at 1000 and Decrement given -1 so the EID will auto generate the values from 1000 by
decreasing 1 value.
In simple manner by using Identity Property, we can auto generate one column per table.
10 SQL Server - SQL Commands Part-1
Start—SSMS (SQL Server Management Studio) – Enter PC Name or (.) & connect to database (“*” is
a default instance)
tempdb is a temporary db that have global resources. As soon as we come out of the server the
tables & everything will drop permanently.
2 User Defined DB
When you create a new database, we will get two files named .mdf & .ldf
.ldf (Log File) – Log when something goes wrong with data file we can refer this file, it is like a
tracker of data file.
Databases
But this is not the we create a db we need to write a command to create a new db.
To do that we have click on “New Query”
“- -abc..“
For writing multiple lines comment we will use
/* a
*/
Syntax Command for create a New DB
Here we can see by using this command we created a new db called “Company”
Now we need to create Tables in the db we created “Company” for that we need to write a command “Use
Database” and we need to click on “Execute” to pointing the “company db”
after executing this we can have the data as per the commands given
go
Syntax for Delete single row from the table
**
we
can use this command for remove a particular cell value by
updating/modifying like this**
we must careful while doing this command because every row value will be changed to new value
and it’s very difficult to get back to the original data.
** here if the data given is perfect then we execute Commit command to save the data once we
use commit, we cannot get back the data by rollback**
Emp name: contains up to 100 character’s & not allows null values
Dep ID: allows null values, foreign key ref Dep(Dep ID)