Home
Search results “Oracle update two tables”
How to Join two tables in a update statement
 
07:18
This video is to understand how we can update a column of a table, based on the data present on the other table, and both the tables having a common column. Its a complicated update statement that can be used to update with different conditions.
Views: 10374 Kishan Mashru
Oracle SQL: Understanding Multiple Table Joins
 
08:10
http://www.informit.com/store/oracle-sql-livelessons-video-training-downloadable-9780134275741?WT.mc_id=Social_YT Oracle SQL: Understanding Multiple Table Joins is an excerpt from Oracle SQL LiveLessons Video Training -- 6+ Hours of Video -- Oracle SQL LiveLessons Video Training covers the basics of the Oracle SQL programming language. This course covers both Oracle standard SQL and the ANSI approved SQL that Oracle supports. The focus of the course is to give students working knowledge of the Oracle SQL language and at the conclusion of this course, students should be able to query the Oracle database. Description In this LiveLessons video course, Oracle ACE Director Dan Hotka will teach you how to use the SQL query language, interpret business questions into SQL code, and how to use Where clauses sub-queries, complex table join conditions, and how to create table objects and populate tables with data. Students will also learn how to access Oracle from Microsoft products such as Excel. In addition, they will learn how analytical SQL can be used for business analysis. This course will use both Toad and SQL Developer for SQL examples. About the Instructor Dan Hotka is a training specialist and an Oracle ACE director who has more than 37 years in the computer industry and more than 31 years of experience with Oracle products. His experience with the Oracle RDBMS dates back to the Oracle V4.0 days. Dan enjoys sharing his knowledge of the Oracle RDBMS. Dan is well published with 12 Oracle books and well over 200 published articles. He is also the video author for Oracle SQL Performance Tuning for Developers LiveLessons and Oracle PL/SQL Programming Fundamentals. He is frequently published in Oracle trade journals, regularly blogs, and speaks at Oracle conferences and user groups around the world. Visit his website at www.DanHotka.com. Skill Level Beginner Learn How To Use the SQL query language Interpret business questions into SQL code Understand Oracle standard SQL and ANSI SQL Work with Where clauses, sub-queries, and complex table join conditions Create table objects and populate these tables with data Access Oracle from Microsoft products such as Excel Use analytical SQL, useful for business analysts Who Should Take This Course Students who are new to SQL and want to learn Oracle SQL Course Requirements Basic knowledge of what is a database, especially RDBMS and what is a computer programming language http://www.informit.com/store/oracle-sql-livelessons-video-training-downloadable-9780134275741?WT.mc_id=Social_YT
Views: 15766 LiveLessons
Update Multiple Table by View
 
23:28
Microsoft SQL Server Update Multiple Table by View
Views: 4299 Joydeep Das
BNMUBCA SEM IV:Joining Multiple Tables in Oracle
 
39:15
Khalid Akhter MCA, MSC (Phy), 16+ years Experience in Software Developement and Training Programs from various IT companies. Ex-Technical Lead in HCL Technology, Kolkata as well as California.
Views: 115 Khalid Akhter
Oracle developer g11- 12- Displaying Data from Multiple tables using joins 2
 
09:21
============ ليصلك كل جديدنا الرجاء الاشتراك في قناتنا من أعلى بالضغط على Subscribe أو من خلال الرابط http://www.youtube.com/subscription_center?add_user_id=C-w3DE8eVjMjx8ffXqvx8w ------------ لمتابعة باقي دورات موقعنا يمكنك زيارتنا على موقع وصفحة وقف أون لاين http://www.waqfonline.com http://www.facebook.com/Waqfonline
How to insert records in multiple tables at same time
 
06:12
How to insert records in multiple table at same time step by step, In this video i'm discus two methods for inserting records in multiple table at same time. #insert #ocptechnology #oracle12c
Views: 48887 OCP Technology
What is join and how to join two tables in oracle database of sql plus
 
01:54
What is join and how to join two tables in oracle database of sql plus. And what are the types of join in oracle database of SQL PLUS.
Views: 359 latest ITChannel
Update Table with inner join in SQL server
 
04:50
Update Table with inner join in SQL server sql server SQL server tutorial SQL server beginner tutorial SQL server tutorial 2016 SQL server interview SQL server interview question SQL server tutorial beginner to advance sql server 2016 tutorial for beginners sql server 2016 sql server interview questions and answer sql tutorial sql tutorial for beginners sql queries tutorial sql server management studio 2016 interview question in sql server
Views: 3264 sadiq msi
Displaying Data from Multiple Tables Using Joins - Oracle SQL Developer
 
10:20
This video covers the following topics: - Joining tables using an equijoin - Performing outer and self-joins - Adding conditions
Views: 3927 MrFphunter
How update multiple values of column with a single UPDATE statement in ms sql server
 
02:17
Is there a way to update multiple columns in SQL server, I would like to update multiple columns in a table based on values,update multiple columns with a single UPDATE statement More @ http://goo.gl/VLYo0Q
Views: 26081 Ajmath Shaik
Oracle ADF: All records from multiple tables with one scrollbar
 
06:58
This video shows how to present all records from several tables in a scrollable panel with just one scrollbar. This is similar to how you would display data from two tables in a pure HTML application where the browser would produce the scrollbar
Views: 2805 Sten Vesterli
Querying Multiple Tables with SQL
 
10:40
Demonstration of how to query two or more tables with SQL Server.
Views: 48578 Larry Domine
MULTI TABLE UPDATE ORACLE FORM BUILDER IN ARABIC
 
08:15
MULTIBLE TABLE UPDATE create table emp10(emp_id number primary key, emp_name varchar2(20), emp_salary number); create table bonus( emp_id number references emp10(emp_id), bonus number); --------------------------------- declare bonus number; begin if :emp_salary علامه اكبر من] 1000 ] then bonus:=:emp_salary * 0.25 ; else bonus:=:emp_salary * 0.5; end if; insert into emp10 values (:emp_id,:EMP_NAME,:EMP_SALARY); INSERT INTO BONUS VALUES(:EMP_ID,bonus); end; commit;
Views: 178 HAMED AL-SAWAFI
ORACLE 11g: Joining of multiple tables in oracle sql | 3i Template IT Solutions
 
19:44
ORACLE 11g: Joining of multiple tables in oracle sql | 3i Template IT Solutions https://youtu.be/oNTm9ZaAwXI how to join multiple tables in oracle 11g joining multiple tables in oracle joining multiple tables in oracle sql joining two tables in oracle joining three tables in oracle joining two tables in oracle sql joining two tables in oracle 11g join three tables in oracle with example join two tables in oracle example join three tables in oracle 11g joining multiple tables in oracle example join between two tables in oracle join between three tables in oracle join two tables in update command oracle how to join two tables in oracle database join two tables in different databases oracle join two tables oracle sql developer left outer join on multiple tables in oracle+example how to join two tables in oracle forms joining two huge tables in oracle how to join multiple tables in oracle how to join multiple tables in oracle sql how to join multiple tables in oracle example how join two tables in oracle inner join multiple tables in oracle inner join two tables in oracle left join multiple tables in oracle join on multiple tables in oracle outer join multiple tables in oracle joining of two tables in oracle joining of three tables in oracle left outer join multiple tables in oracle outer join two tables in oracle oracle join multiple tables performance query to join multiple tables in oracle how to join two tables in oracle reports joining more than two tables in oracle sql inner join multiple tables oracle sql combine two tables oracle sql oracle join multiple tables syntax to join two tables in oracle join two tables in update oracle join two unrelated tables in oracle join with multiple tables in oracle how to join two tables in oracle without common column Please Subscribe: https://www.youtube.com/channel/UC6tweEO2qzGGWXHGFXfe1Ow Facebook: https://www.facebook.com/3iTemplateItSolutions ORACLE 11g: Joining of multiple tables in oracle sql | 3i Template IT Solutions https://youtu.be/oNTm9ZaAwXI
Views: 1232 3i Tutorials For All
SQL Server Update with joining two or more table | SQL Server | Jangli Coder
 
08:20
SQL Server Update With Joining Two or More Table, SQL Server Update Query, Update Query with join, join in update query, inner join, left join, full join, Facebook Page :- https://goo.gl/fuhjF1 Youtube :- https://goo.gl/UqixKZ blogspot :- https://goo.gl/3Q7VCw Please Like, Comment and Subscribe Our Channel
Views: 754 Jangli Coder
SQL: using JOIN in UPDATE Query
 
09:36
This video demonstrates how we can join tables for updating a record in a table. Above example shows how to write an update query to set products of category mobile from a particular supplier ABC not to be sold.
Views: 13992 Gautam Mokal
Oracle SQL Developer Tutorial For Beginners   77   JOIN Two Tables
 
02:04
Oracle SQL Developer Tutorial For Beginners Series. This course introduces Oracle SQL Development for its subscribers. Currently this is based on Oracle 12c. The test environment is in Windows 10.
Views: 1794 Sam Dhanasekaran
14-Oracle SQL- Displaying Data From Multiple Tables
 
12:30
TrainerBD.com Offers the most affordable (BDT. 15,000/-) Oracle Training in Mirpur, Dhaka, Bangladesh. Learn Oracle, Be an Oracle Developer and/or Database Administrator. Click http://www.trainerbd.com/training/product/oracle-training-in-bangladesh/ to learn Oracle. Oracle Tutorial Group (Facebook):- https://www.facebook.com/groups/Oracletutorialvideos https://www.facebook.com/groups/oracletutorialtechtunes Search Terms:- oracle video tutorial free download oracle applications tutorial oracle 11g tutorial free download oracle sql tutorial oracle 10g tutorial oracle form builder tutorial oracle forms 10g tutorial oracle 10g tutorial for beginners oracle database 10g tutorial sql oracle oracle for beginners oracle 10g tutorial oracle tutorials for beginners oracle dba tutorial for beginners pdf oracle forms developer tutorial toad for oracle tutorial oracle fusion middleware tutorial oracle forms 6i tutorial oracle sql tutorial oracle 11g tutorial oracle tutorial pdf free download oracle dba tutorial for beginners oracle application express tutorial oracle tutorial for beginners oracle database tutorial oracle apex tutorial oracle sql tutorial sql tutorial oracle 11g tutorial oracle 10g tutorial oracle dba tutorial oracle tutorial for beginners Tags: oracle video tutorial free download,oracle applications tutorial,Oracle 11g tutorial free download,oracle sql tutorial,oracle 10g tutorial,oracle form builder tutorial,oracle forms 10g tutorial,oracle 10g tutorial for beginners,oracle database 10g tutorial,sql oracle,oracle for beginners,oracle tutorials for beginners,oracle forms developer tutorial,toad for oracle tutorial,oracle fusion middleware tutorial,
Views: 433 Oracle Tutorialbd
11 of 15 SQL Basics with Oracle - Using two or more tables in a query
 
07:46
This video explains how to get data from 2 or more tables. Two methods are explained: the WHERE clause and the JOIN operator. Examples of each are shown. (11 of 15) There is also an "Advanced SQL" series. (Search for "databasemec" for tutorials using SQL Server.)
Views: 3314 Jennifer Kreie
MERGE columns from two tables (DML Commands) | Oracle SQL fundamentals
 
08:20
Enroll into full course with free cloud access for 30 days: https://dbagenesis.com/p/oracle-sql-fundamentals/
Views: 98 DBA Genesis
Joining Many Tables (Introduction to Oracle SQL)
 
07:52
Find out how to join many tables together in SQL. The full Introduction to Oracle SQL course is available here: https://www.databasestar.com/introduction-to-oracle-sql-course/
Views: 817 Database Star
Oracle Database | Bangla Tutorials 18 :: Update Statement (Row Update in table))
 
03:17
www.facebook.com/oracle.shohag Email : [email protected] Website : www.oraclebangla.com Topics : Update Statement (Row Update in table)
Views: 1300 Oracle Bangla
Updating a Table with SSIS
 
06:19
Updating a Table with SSIS
Views: 106601 Rick Caminiti
Oracle Class15- Displaying Data from Multiple Tables
 
15:53
Website: http://javaknowledge.info Source code: http://www.trainingwithliveproject.com FB Page: https://www.facebook.com/javaknowledgeshare FB Group: https://www.facebook.com/groups/PBPTBD
Views: 340 Java Knowledge
How to join or relation between two table in Oracle SQL
 
16:47
How to join or relation between two table in Oracle SQL
Oracle Database11g tutorials 14 : How to CREATE TABLE using sql developer and command prompt
 
08:36
Oracle Database11g tutorials 14 How to Create table using command prompt and Create table using sql developer Blog Link http://bit.ly/1TkY4Oe Time Line 0:25 Introduction of Tables in Database 1:03 What is Create Table (Introduction of create table) 1:30 Syntax of Create Table 2:08 How to create table using Command Prompt 4:55 How to create table using SQL Developer Links for Oracle Database tutorials 4: database connectivity using SQL developer and command prompt http://youtu.be/wSqoXRlXDUU You can have indepth knowledge about SQL create table here http://www.rebellionrider.com/sql-create-table.html Tool used in this tutorial is command prompt. This tutorial series is part of SQL expert exam certification training. if you are preparing for SQL certification you can use my tutorials. This SQL Tutorial is a part of free training. Copy Cloud referral link || Use this link to join copy cloud and get 20GB of free storage https://copy.com?r=j7eYO7 Contacts E-Mail [email protected] Twitter https://twitter.com/rebellionrider Instagram http://instagram.com/rebellionrider Facebook. https://www.facebook.com/imthebhardwaj Linkedin. http://in.linkedin.com/in/mannbhardwaj/ Thanks for linking, commenting, sharing and watching more of our videos This is Manish from RebellionRider.com Today in this oracle database tutorial we will see How to CREATE A TABLE. if we have to define a table in layman language then we can say that Tables are just a collection of Rows and Columns but In RDBMS tables are database objects which help in organizing data into ROWS and COLUMNS. We can also say that SQL tables are kind of data structure which are used by database for efficient storage of data. To create a table in our database we use SQL CREATE TABLE command. SQL CREATE TABLE is a type of DATA DEFINITION LANGUAGE also known as DDL. To Create a table in your schema you will require CREATE TABLE system privilege. In our future videos we will see what are system and object privileges and how to grant them to a user. Today for this video we will be using Sample schema HR which already has all the necessary privileges. Ohk Let's see the syntax. CREATE TABLE table name ( column name1 Data-Type(size), column name2 Data-Type(size), ..... ); CREATE TABLE is an oracle reserved word or say an Oracle key word whereas There are 3 different ways of creating a table in Oracle database. Creating a table using Command Line Interface (CLI) in Oracle database For demonstrating how to create table in oracle database using CLI, I'll be using Command prompt. Thats how we create table using command prompt. you can check your table structure by DESCRIBE command for that just write DESC and your table name. Like this Another way of creating a table is by using Graphic user interface (GUI) in Oracle database To demonstrate how to create table using GUI we will use SQL developer. Lets open our SQL developer I am connected to HR schema if you do not know how to create a connection to database using SQL developer please watch my oracle database tutorial 4 that explains database connectivity using SQL developer and command prompt. Link for this video is in the description below. So lets create a table. Creating a table using SQL developer is very easy we do not have to fire any query here. Let's start First of all right click on your connection in which you want to create a table and choose schema browser. This will open a separate schema browser pane or you can expend your connection by clicking this + sign and then right click on table and choose New Table. However I prefer working with schema browser so let's skip to schema browser pane here from the first drop-down list you can choose connection name and in the second drop down list you can choose what database objects you want to work with we want to create a table thus I'll choose table and then click this arrow here and choose option for new table Ok we have created a table wizard first of all give a unique name to your table and add some column as well. For this, click the green plus button. Now we already have a column so give it some name. Also choose a datatype from the list and specify any size you can check this not null column if in case you want to make this a mandatory column you can also specify default value and constraint If you want to make this column a primary key you can click here In my future video i'll show you what are these constraints and different ways of applying them on a column in a table. for this video we will concentrate on create table only so when you are done with all your columns click ok Thats your table You can double click on your table here and can see its structure. Thats it
Views: 191509 Manish Sharma
SQL Update Statement using Example in Oracle 11g Database
 
05:27
SQL tutorial for beginners in hindi and english SQL Update Statement using Example in Oracle 11g Database
How to Fetch Latest record/row from the Table in Oracle Database
 
03:32
You will learn how to How to Fetch Latest record/row from the Table in Oracle Database. Realtime Scenario: This logic can be implemented to find whether the latest record should be inserted or updated to datawarehouse
13 02  Multiple Table UPDATE
 
05:53
MYSQL 5 DEVELOPMENT
Views: 1339 Miszkoxxx
Oracle - SQL - Alter Table
 
09:02
Oracle - SQL - Alter Table Watch more Videos at https://www.tutorialspoint.com/videotutorials/index.htm Lecture By: Mr. Anadi Sharma, Tutorials Point India Private Limited.
join two table in oracle form builder
 
40:06
how to make a emp_incentive table in oracle form builder
Oracle developer g11- 11- Displaying Data from Multiple tables using joins
 
20:49
============ ليصلك كل جديدنا الرجاء الاشتراك في قناتنا من أعلى بالضغط على Subscribe أو من خلال الرابط http://www.youtube.com/subscription_center?add_user_id=C-w3DE8eVjMjx8ffXqvx8w ------------ لمتابعة باقي دورات موقعنا يمكنك زيارتنا على موقع وصفحة وقف أون لاين http://www.waqfonline.com http://www.facebook.com/Waqfonline
Oracle Join Tables تعليم أوراكل
 
14:23
by Mohamed El Desouki - محمد الدسوقى [email protected] Tel :00966 553450836 جامعة سلمان بن عبد العزيز - السعودية - الخرج How to select data from more than one table using Join. كيفية الربط بين أكثر من جدول Text Book: Fundamentals of Database Systems, 5th Edition, by Elmasri/Navathe, published by Addison-W oracle create table statement oracle drop table statement oracle constraints database constraints primary key constraint foreign key constraint check constraint null not null constraint unique constraint insert into statement update statement delete statement select statement basic query where clause select where Like '%' Like '_' select where Like Join Tables inner join equi join
Oracle Database | Bangla Tutorials 14  :: Displaying Data From Multiple Tables (Table Joining))
 
09:52
www.facebook.com/oracle.shohag Email : [email protected] Website : www.oraclebangla.com Topics : Displaying Data From Multiple Tables
Views: 2686 Oracle Bangla
Java Database Tutorial - Update Multiple Tables
 
12:10
Please Rate, Comment and Subscribe.
Views: 25922 Naveed Ziarab
ORACLE ADVANCED - QUERY WITH DIFFERENT TABLES
 
31:07
tutorial WDT (world deaf tech)
Views: 459 Gabriele Serpi
Oracle Tutorial - Add Comment on a Table and Column | Remove Comment
 
09:36
Oracle Tutorials: Add Comment on a Table and Column | Remove Comment from a Table and Column
Views: 228 Tech Acad
Learn Oracle | How to Update a Table using SQL
 
02:10
Pebbles present, Learn Oracle 10g with Step By Step Video Tutorials. Learn Oracle 10g Tutorial series contains the following videos : Learn Oracle - History of Oracle Learn Oracle - What is Oracle - Why do we need Oracle Learn Oracle - What is a Database Learn Oracle - What is Grid Computing Learn Oracle - What is Normalization Learn Oracle - What is ORDBMS Learn Oracle - What is RDBMS Learn Oracle - Alias Names, Concatenation, Distinct Keyword Learn Oracle - Controlling and Managing User Access (Data Control Language) Learn Oracle - Introduction to SQL Learn Oracle - Oracle 10g New Data Types Learn Oracle - How to Alter a Table using SQL Learn Oracle - How to Create a Package in PL SQL Learn Oracle - How to Create a Report in SQL Plus Learn Oracle - How to Create a Table using SQL - Not Null, Unique Key, Primary Key Learn Oracle - How to Create a Table using SQL Learn Oracle - How to Create a Trigger in PL SQL Learn Oracle - How to Delete Data from a Table using SQL Learn Oracle - How to Drop and Truncate a Table using SQL Learn Oracle - How to Insert Data in a Table using SQL Learn Oracle - How to open ISQL Plus for the first time Learn Oracle - How to Open SQL Plus for the First Time Learn Oracle - How to Update a Table using SQL Learn Oracle - How to use Aggregate Functions in SQL Learn Oracle - How to use Functions in PL SQL Learn Oracle - How to use Group By, Having Clause in SQL Learn Oracle - How to Use Joins, Cross Join, Cartesian Product in SQL Learn Oracle - How to use Outer Joins (Left, Right, Full) in SQL Learn Oracle - How to use the Character Functions, Date Functions in SQL Learn Oracle - How to use the Merge Statement in SQL Learn Oracle - How to use the ORDER BY Clause with the Select Statement Learn Oracle - How to use the SELECT Statement Learn Oracle - How to use the Transactional Control Statements in SQL Learn Oracle - How to use PL SQL Learn Oracle - Data Types in PL SQL Learn Oracle - Exception Handling in PL SQL Learn Oracle - PL SQL Conditional Logics Learn Oracle - PL SQL Cursor Types - Explicit Cursor, Implicit Cursor Learn Oracle - PL SQL Loops Learn Oracle - Procedure Creation in PL SQL Learn Oracle - Select Statement with WHERE Cause Learn Oracle - SQL Operators and their Precedence Learn Oracle - Using Case Function, Decode Function in SQL Learn Oracle - Using Logical Operators in the WHERE Clause of the Select Statement Learn Oracle - Using Rollup Function, Cube Function Learn Oracle - Using Set Operators in SQL Learn Oracle - What are the Different SQL Data Types Learn Oracle - What are the different types of Databases Visit Pebbles Official Website - http://www.pebbles.in Subscribe to our Channel – https://www.youtube.com/channel/UCNNjWVsQqaMYccY044vtHJw?sub_confirmation=1 Engage with us on Facebook at https://www.facebook.com/PebblesChennai Please Like, Share, Comment & Subscribe
Views: 204 Pebbles Tutorials
Oracle Tutorials || Adv Sql||External tables part-1 by Basha
 
33:27
DURGASOFT is INDIA's No.1 Software Training Center offers online training on various technologies like JAVA, .NET , ANDROID,HADOOP,TESTING TOOLS ,ADF,INFORMATICA,TABLEAU,IPHONE,OBIEE,ANJULAR JS, SAP... courses from Hyderabad & Bangalore -India with Real Time Experts. Mail us your requirements to [email protected] so that our Supporting Team will arrange Demo Sessions. Ph:Call +91-8885252627,+91-7207212428,+91-7207212427,+91-8096969696. http://durgasoft.com http://durgasoftonlinetraining.com https://www.facebook.com/durgasoftware http://durgajobs.com https://www.facebook.com/durgajobsinfo......
Oracle Database: How-To: Insert values into a Table
 
07:02
The Best Site to Learn SQL Online
Views: 35958 TechnicalSkills
Oracle Database bangla Tutorials 19 :: delete statement (Row Delete in Table)
 
01:56
www.facebook.com/oracle.shohag Email : [email protected] Website : www.oraclebangla.com Topics : Update Statement (Row Update in table)
Views: 795 Oracle Bangla
Complex Joins in Tableau
 
09:52
In this tutorial video, we will be going over complex joins in Tableau. We'll talk about: - How to join more than two tables together, - What data is included and excluded for various types of joins, - How your joins affect calculations in your views, and more. We'll also be talking briefly about how Level of Detail expressions can be used with joined data that has duplicate records. Boulder Insight - http://boulderinsight.com/ Blog - http://boulderinsight.com/index.php/boulder-insight-blog/
Views: 69033 Boulder Insight
Oracle developer g11  11  Displaying Data from Multiple tables using joins
 
20:49
Learn Oracle developer g11 كورس Oracle developer g11
Views: 81 MyVideo Walid
ORACLE SQL- 3.insert row into table
 
08:35
we will insert a row into the table and how to modify it and all will be shown here
Views: 233 Ban3 GaiN
add primary key and foreign key to join two table in oracle database
 
05:44
add primary key and foreign key to join two table in oracle database
SQL script to insert into many to many table
 
14:52
Text Article http://csharp-video-tutorials.blogspot.com/2017/02/sql-script-to-insert-into-many-to-many.html Slides http://csharp-video-tutorials.blogspot.com/2017/02/sql-script-to-insert-into-many-to-many_6.html SQL Server Interview Questions and Answers text articles & slides http://csharp-video-tutorials.blogspot.com/2014/05/sql-server-interview-questions-and.html SQL Server Interview Questions and Answers playlist https://www.youtube.com/playlist?list=PL6n9fhu94yhXcztdLO7i6mdyaegC8CJwR All Dot Net and SQL Server Tutorials in English https://www.youtube.com/user/kudvenkat/playlists?view=1&sort=dd All Dot Net and SQL Server Tutorials in Arabic https://www.youtube.com/c/KudvenkatArabic/playlists In this video we will discuss how to insert data into a table that has many-to-many relationship Create table Students ( Id int primary key identity, StudentName nvarchar(50) ) Go Create table Courses ( Id int primary key identity, CourseName nvarchar(50) ) Go Create table StudentCourses ( StudentId int not null foreign key references Students(Id), CourseId int not null foreign key references Courses(Id) ) Go Students - Id column is identity column Courses - Id column is identity column StudentCourses - StudentId and CourseId columns are foreign keys referencing Id column in Students and Courses tables As you can see, StudentCourses is a bridge table that has many to many relationship with Students and Courses tables. This means a given student can be enrolled into many courses and a given course can have many students enrolled. Below is the question asked in an interview for SQL Server Developer role. Write a SQL script to insert data into StudentCourses table. Here are the rules that your script should follow. 1. There will be 2 inputs for the script Student Name - The name of the student who wants to enroll into a course Course Name - The name of the course the student wants to enroll into 2. If the student is already in the Students table, then use that existing Student Id. If the student is not already in the Students table, then a row for that student must be inserted into the Students table, and use that new student id. 3. Along the same lines, if the course is already in the Courses table, then use that existing Course Id. If the course is not already in the Courses table, then a row for that course must be inserted into the Courses table, and use that new course id. 4. There should be no duplicate student course enrollments, i.e a given student must not be enrolled in the same course twice. For example, Tom must not be enrolled in C# course twice. Answer : To avoid duplicate student course enrollments create a composite primary key on StudentId and CourseId columns in StudentCourses table. With this composite primary key in place, if someone tries to enroll the same student in the same course again we get violation of primary key constraint error. Alter table StudentCourses Add Constraint PK_StudentCourses Primary Key Clustered (CourseId, StudentId) Here is the SQL script that inserts data into the 3 tables as expected Declare @StudentName nvarchar(50) = 'Sam' Declare @CourseName nvarchar(50) = 'SQL Server' Declare @StudentId int Declare @CourseId int -- If the student already exists, use the existing student ID Select @StudentId = Id from Students where StudentName = @StudentName -- If the course already exists, use the existing course ID Select @CourseId = Id from Courses where CourseName = @CourseName -- If the student does not exist in the Students table If (@StudentId is null) Begin -- Insert the student Insert into Students values(@StudentName) -- Get the Id of the student Select @StudentId = SCOPE_IDENTITY() End -- If the course does not exist in the Courses table If (@CourseId is null) Begin -- Insert the course Insert into Courses values(@CourseName) -- Get the Id of the course Select @CourseId = SCOPE_IDENTITY() End -- Insert StudentId & CourseId in StudentCourses table Insert into StudentCourses values(@StudentId, @CourseId) If required, we can very easily convert this into a stored procedure as shown below. Create procedure spInsertIntoStudentCourses @StudentName nvarchar(50), @CourseName nvarchar(50) as Begin Declare @StudentId int Declare @CourseId int Select @StudentId = Id from Students where StudentName = @StudentName Select @CourseId = Id from Courses where CourseName = @CourseName If (@StudentId is null) Begin Insert into Students values(@StudentName) Select @StudentId = SCOPE_IDENTITY() End If (@CourseId is null) Begin Insert into Courses values(@CourseName) Select @CourseId = SCOPE_IDENTITY() End Insert into StudentCourses values(@StudentId, @CourseId) End Use the following statement to execute the stored procedure Execute spInsertIntoStudentCourses 'Tom','C#'
Views: 99753 kudvenkat
Oracle Tutorial ||online training|| Display Data from Multiple Tables using JOINS
 
40:44
DURGASOFT is INDIA's No.1 Software Training Center offers online training on various technologies like JAVA, .NET , ANDROID,HADOOP,TESTING TOOLS ,ADF,INFORMATICA,TABLEAU,IPHONE,OBIEE,ANJULAR JS, SAP... courses from Hyderabad & Bangalore -India with Real Time Experts. Mail us your requirements to [email protected] so that our Supporting Team will arrange Demo Sessions. Ph:Call +91-8885252627,+91-7207212428,+91-7207212427,+91-8096969696. http://durgasoft.com http://durgasoftonlinetraining.com https://www.facebook.com/durgasoftware http://durgajobs.com https://www.facebook.com/durgajobsinfo......