Spark SQL Tutorial 12 | Null Check On Table Spark SQL | Spark Tutorial | Data Engineering
Summary
TLDRThis video tutorial from Sahu Studies IN introduces viewers to the process of creating and managing a non-null check table using SQL. The presenter demonstrates how to define columns, data types, and a not-null constraint. They then show how to insert records, alter the table to change column names, and drop the not-null constraint. The tutorial also covers the creation of a document fragment and the importance of not allowing null values in certain columns to maintain data integrity. The video concludes with a demonstration of how to select records from the table, emphasizing the practical application of the concepts discussed.
Takeaways
- 😀 The video is a tutorial on how to create a non-null check table in a database using SQL.
- 🔍 The presenter explains the process of defining columns, their data types, and setting a column as NOT NULL.
- 📝 The importance of NOT NULL constraints is highlighted to ensure data integrity during the insert process.
- 💾 A demonstration is provided on how to insert records into the table while adhering to the NOT NULL constraints.
- 🔧 The video covers the use of the ALTER TABLE command to modify the table schema, including changing column names and dropping NOT NULL constraints.
- 🔄 The process of updating records in the table is shown, emphasizing the need to handle NOT NULL columns correctly.
- 🚫 The presenter warns about the consequences of attempting to insert NULL values into NOT NULL columns and how to avoid it.
- 🗂️ The video includes a segment on how to remove the NOT NULL constraint from a column if necessary.
- 🔎 There is a discussion on how to check for the presence of NOT NULL constraints in a table using the schema information.
- 🛠️ The presenter uses a CREATE TABLE command to demonstrate the initial setup of a table with NOT NULL constraints.
- 📈 The tutorial concludes with a summary of how to manage NOT NULL constraints to maintain data consistency in a database.
Q & A
What is the purpose of the video?
-The purpose of the video is to demonstrate how to work with a 'NOT NULL' check in a table using SQL, including creating, inserting, and altering the table.
What does 'NOT NULL' mean in SQL?
-'NOT NULL' is a constraint in SQL that ensures a column must not be left empty or null when inserting or updating records in a table.
How is a table created in the video?
-A table is created using a 'CREATE TABLE' command with the help of a 'CREATE' statement, defining columns, their data types, and the 'NOT NULL' constraint where necessary.
What is a 'CREATE TABLE' command used for?
-A 'CREATE TABLE' command is used to create a new table in a database with specified columns and their data types, along with any constraints such as 'NOT NULL'.
How can records be inserted into a table with 'NOT NULL' constraints?
-Records are inserted using an 'INSERT INTO' statement, ensuring that values are provided for all 'NOT NULL' columns to avoid violation of the constraint.
What happens if you try to insert a NULL value into a 'NOT NULL' column?
-Attempting to insert a NULL value into a 'NOT NULL' column will result in an error, as the database will not allow the operation to proceed, enforcing the constraint.
How can the 'NOT NULL' constraint be removed from a column?
-The 'NOT NULL' constraint can be removed by using an 'ALTER TABLE' statement to modify the column and drop the 'NOT NULL' constraint.
What is the use of an 'ALTER TABLE' statement?
-An 'ALTER TABLE' statement is used to make changes to the structure of a table, such as adding, dropping, or modifying columns, including removing 'NOT NULL' constraints.
How can you check if a table has been created successfully?
-You can check if a table has been created successfully by using a 'SELECT' statement to query the table and see if it returns the expected structure and data.
What is the significance of the 'DROP' keyword in the context of this video?
-The 'DROP' keyword is used to remove or delete a table or a column's 'NOT NULL' constraint, allowing for structural changes to the database schema.
How can you rename a column in a table?
-A column can be renamed using an 'ALTER TABLE' statement with the appropriate syntax to change the column's name while maintaining its data and constraints.
Outlines
😀 Introduction to Creating a Table with NOT NULL Constraints
This paragraph introduces the process of creating a table in a database using SQL. It explains the steps to define a table with six columns, including data types and the NOT NULL constraint to ensure data integrity. The speaker also mentions inserting records into the table and the importance of the NOT NULL constraint for certain columns to prevent the insertion of null values.
😀 Inserting Records and Altering Table Structure
The second paragraph discusses inserting records into the previously created table and the potential issues that may arise if null values are not allowed for certain columns. It also covers how to alter the table structure by adding or changing column names and dropping the NOT NULL constraint if necessary. The speaker emphasizes the importance of careful planning when altering tables and the steps to successfully update the table schema.
Mindmap
Keywords
💡No Null Check
💡Create Table
💡Column
💡Data Type
💡Insert Record
💡Constraint
💡Alter Table
💡Drop Constraint
💡Data Integrity
💡Database Management
💡Script
Highlights
Introduction to Sahu Studies In, discussing how to put a not null check in a table using SQL.
Creating a table with the help of a CREATE TABLE command, defining six columns and their data types.
One of the columns named 'name' is set as NOT NULL to prevent null values.
Demonstration of inserting a record into the table without null values for the 'name' column.
Explanation of how the NOT NULL constraint is enforced during the insert process.
Capturing the output to show that records have been successfully inserted into the table.
Creating a document fragment to implement NOT NULL check over a column.
Altering a table to change the column name and dropping the NOT NULL condition.
Using the ALTER TABLE statement to modify the table structure and constraints.
Dropping the NOT NULL constraint from the 'name' column to allow null values.
Explanation of how to remove the NOT NULL check using the ALTER TABLE command.
Providing training on table creation and manipulation with NOT NULL constraints.
Demonstration of creating a table with NOT NULL check using a running cluster.
Connecting to a database to create a table with NOT NULL constraints if not already existing.
Inserting records into the table with NOT NULL values for specific columns.
Ensuring that the insert statement does not take place if null values are provided.
Duplicating the NOT NULL check by setting it for another column in the table.
Finalizing the process by showing the successfully created table with NOT NULL constraints.
Encouraging viewers to like, subscribe, and comment on the video for more content.
Transcripts
हेलो फ्रेंड्स वेलकम टू साहू स्टडीज इन
दिस वीडियो वी आर गोइंग टू सी हाउ कैन वी
पुट अ नोट नल चेक इन अ
टेबल यूजिंग स्पा
एल सो व्हाट आई एम गोइंग टू डू इन दिस
एक्सरसाइज टू चेक नोट नल आई एम गोइंग टू
क्रिएट अ टेबल विद द हेल्प ऑफ अ क्रिएट
टेबल कमांड द नेम ऑफ द टेबल इज दिस वन आई
एम
डिफाइनिंग सिक्स
कॉलम्स एंड इट्स डाटा टाइप एंड वन ऑफ कॉलम
ए नेम स्टिंग वी आर पुटिंग इट नॉट नल ट
मीस नवर वी आर गोइंग टू इंसर्ट अ रिकर्ड
इन दिस टेबल दिस कॉलम मस्ट नॉट बी नल इफ ट
कॉलम ड बी नल देन द इंशन प्रोसेस विल नॉट
गोइंग टू टेक प्लेस सो आई हैव
कैप्चरड दिस आउटपुट एज वेल
सो यू कैन सी व आर
रिकॉर्ड्स इन दिस टेबल च वी हैव
क्रिएटेडॉक्युमेंट्सफ्रैगमेंट
इंप्लीमेंटेड नट नल चेक ओवर दिस कॉलम एंड
इट वालेट द कंस्ट्रेंट च वी हैव
इंप्लीमेंटेड इन ट कॉलम टस वाई दिस ट
स्टेटमेंट ल नॉट गोइंग टू टेक प्लेस ट वी
कैन डू वन वी कैन जस्ट रिमूव दिस वीन
रिमूव दिस
ननल चक हाउ कैन व रिमूव ट व कैन रिमूव ट
वि हेल्प ल्टर र वी हैव टू
प्रोवाइड ट टरिंग टेबल एंड दिस इ द नेम ऑफ
द टेबल च वी आर गोइंग टू ल्टर एंड यर वी
आर गोइंग टू चेंज
कॉलम ए
नेम एंड ी ड्रॉपिंग ननल कंडीशन सो यर वट
वी आर डूइंग वि हेल्प वि हेल्प ऑफ ल्टर
टेबल स्टेटमेंट वी आर ड्रॉपिंग द
कंस्ट्रेंट च वी हैव इंप्लीमेंटेड ओवर दिस
कॉलम वी कैन सी हियर ए अंडर नेम वी आर
ड्रॉपिंग ऑल ड्रॉपिंग नॉट नल नॉट नल चेक
विच वी हैव इंप्लीमेंटेड हियर एंड वंस वी
हैव एबल टू ड्रॉप द नॉट नल चेक फ्रॉम एपी
नेम कॉलम एंड इफ यू वांट टू इंसर्ट द
रिकॉर्ड इन इट विद दिस नल वैल्यू दिस
इंस्टेंट स्टेटमेंट विल गोइंग टू टेक
प्लेस सो लेट्स सी हाउ दिस विल गोइंग टू
वर्क इन डेटा बक्स सो लेट्स गो टू द डेटा
क्रिएट
नोटबुक नेम इट एस नट नल
चेक नट नल चेक
लेट्स कनेक्ट दिस विथ आवर रनिंग
क्लस्टर लेट्स क्रिएट टेबल हाउ कैन व
क्रिएट टेबल व कैन क्रिएट वि हेल्प क्रिएट
टेबल इफ नॉट एजिस्ट एंड व्ट इ द नेम ऑफ द
टेबल
ए ए
एप्ल नट
नल चेक दिस इ द नेम ऑफ
टेबल
एंड स्कीमा ऑ टेबल
इ आईडी इ ऑफ इ टाइप देन
ए नेम इज ऑफ स्ट्रिंग टाइप एंड वी आर
पुटिंग नॉट नल चेक हियर देन
एप जेंडर इ ऑफ स्टिंग ऑफ स्ट्रिंग
टाइप देन
ए एपी सैलरी इ ऑफ इन टाइप देन
एपी स्टेट ऑफ स्ट्रिंग टाइप एंड
एप सीटी ऑफ स्ट्रिंग टाइप
लेट्स रन
ट इ टेकिंग सम टाइम लेटस
वेट सी दिस टेबल है बन कटेड सक्सेसफुली फम
हियर दिस इ द डिफॉल्ट टेबल एंड हियर दिस
एपी एप्ल नॉट नल चेक दिस टेबल हैज बीन
क्रिएटेडटेड दिस कॉलम वी आर गोइंग टू
इंसर्ट नल लेट्स सी व्ट इट विल हैपन सो
इंसर्ट
इनटू दिस इज द नेम ऑफ द
टेबल वल
आर ग ू इर्ट
ट यर व आर इनर्टिंग नल देन र इटिंग
मेल देन व आर इंसर्टिंग
सैलरी एन इनर्टिंग
स्टेट एंड देन इटिंग
स
ट
व पमें नक स्ट सो इ चेकिंग नट वैल्यू च व
आर वी आर गोइंग टू इंसर्ट इन दिस टेबल दिस
कॉलम कंट नल इ इ कॉलम कन डोंट अलाउ द इंशन
सो सेम थिंग इ सेट न नल कांस्टेंट लेट फॉर
द कॉलम
ए नाउ लेट्स डप दिस ननल चक
इर्ट सो हाउ व आर गोइंग टू ड लेट
ल्टर टेबल च टेबल वी आर गोइंग टू ल्टर व
आर गोइंग टू ल्टर दिस टेबल
चेंज कॉलम च कॉलम
ए नेम ट व्ट वी वांट टू चेंज वी आर
ड्रॉपिंग ड नट नल चक सो वट वी आर सी वी आर
अल्टरिंग दिस टेबल एंड वी आर ड्रॉपिंग दन
चेक ऑस
ए नेम कॉलम लेटस
रन
ओके न नल नस कॉलम है सक्सेसफुली ड नाउ
लेटस
इर्ट दिस स्टेटमेंट
अगेन
वी कैन सी दिस स्टेटमेंट है फाइनली
प्रोसेस बिकॉज वी हैव लडी डप
दिस न नल चेक फम ए नेम ट्स वाई इट टेकिंग
नल वैल्यू ए वेल सो लेट्स डू सेलेक्ट ओवर
दिस
टेबल
न सी रिकर्ड च प्रजेंट इनस टेबल ए न ऑफ ड
च इ
नेम सो इन दिस वीडियो वी हैव सीन हाउ कैन
वी पुट चिक नोट न न पर्टिकुलर कॉलम ए हाउ
वी कैन एबल टू ड्रॉप द नॉट नल चेक च वी
हैव इंप्लीमेंटेड इन वन ऑफ द कॉलम लेट्स
गो टू द
प थैंक यू इफ यू लाइक कंटेंट ऑफ माय
वीडियो देन प्लीज सब्सक्राइब माय चैनल
लाइक इट कमेंट ऑन इट एंड प्रेस द बेल आइकन
टू गेट नोटिफिकेशन व्हेन एवर आई ड वीडियोस
تصفح المزيد من مقاطع الفيديو ذات الصلة
5.0 / 5 (0 votes)