Oracle Database11g tutorials 13 || SQL substr function / SQL substring function
Key Takeaways
Explains the SQL substr function in Oracle Database 11g
Full Transcript
hey YouTube welcome back once again this is Manish from dealer.com today in this Oracle database video we will see second character manipulation function which is SQL substa function as the name suggest SQL subst function will return sub string from the given Source string let's see the syntax as we can see SQL subst function takes three parameter first one is Source string from which you want to extract the segment second parameter is a starting position of the sub string from The Source string and the third parameter is substr length which is the length of the sub string first two parameters are mandatory to specify while the third one is optional so we can see SQL substr function will return return a sub string of a specified length from a source string beginning at a given position first parameter Source string can be of any data type care where care to n care andw care to clob or n clo whereas both start position and subst length parameters must be number data type the returning result of SQL subsq function is of same data type of source string let's see some example okay here we are on SQL Developer let's do some example here in this query URL of my website ww. Rebellion rider.com is our source string with the total length of 22 characters now I want to extract the name of my website that is rebellion Rider so if you count the total length of the name of the website it is 14 that's why I have specified 14 as my third parameter of SQL substr function which is substr lens also the name of the website Rebellion Rider is starting from the fifth position therefore I have specified five at second parameter of SQL substr function which is start pose or starting position execute it here is our result Rebellion Rider there are few scenarios related to SQL substr function let's check them first scenario when a starting position is larger than the length of source string in this case SQL subst strr function will return null as a result Let's do an example as you can see here I have specified 23 at starting position and the total length of our source string is 22 characters let's execute and the result is null second scenario when the subst Str length is greater than the source string in this case is the segment return is the sub string from starting position to the end of the string for example our starting position is at 5 means at the first hour of rebellion Rider and the length of sub string is set to 23 which is greater than the length of source string that is 22 execute as you can see we get a sub string from first R of rebellion Rider till the end of source string third scenario when you supply numeric or arithmetic expression or a date instead of character s Source string to SQL substr function in this scenario if you have supplied a numeric string instead of a character as source string the Oracle engine cast them as a corrector when they occur as a parameter to SQL substa function and if you have supplied arithmetic expression or a date then the Oracle engine first solve or evaluates the arithmetic expression or the date then cast them as a corrector means if you have arithmetic expression in your Source string then Oracle will first solve it and then change or say cast the value of its result into corrector let's see some examples Oracle first evaluates the arithmetic operation that is 50,000 - 7 = to 49,93321 character string means 49,990 will be a five cor string starting position of sub string is two that means from the first n of 49,990 we specified the length of Serv string is four so we must get 9,993 as a result let's check execute here is result similarly if you give a CIS deed as your Source string it first get evaluated and then gets casted Let's do an example I have a specified CIS date here without any quote so that you can see that CIS date first get converted into date then get casted into corrector string by SQL Serv function let's execute here is our result there are other scenarios also such as what if starting position is zero or if it's a negative number or third parameter subst strr length is omitted for these scenarios please read my blog I have explained everything there you can find the link of this blog in the video description below that's it for today hope you enjoyed watching this video don't forget to subscribe and like I'll see you in the next video soon thanks for watching this is Manish from Rebellion Rider
Original Description
link of SQL substr blog :
http://www.rebellionrider.com/SQL-substr-function.htm
SQL substr function
SQL Substr function will return a sub string of a specified length from the source string beginning at a given position.
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
RebellionRiderYT@gmail.com
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
----------------------------------------------------------------------------
As the name suggests SQL Substr function will return substring from a given source string.
Let's see the Syntax
Substr (source_string, start_pos, Substr_length)
As we can see SQL substr function takes 3 parameters. First one is Source string from which you want to extract the segment.
Second parameter is Starting position for sub string from the Source string.
And the third parameter is Substr_length which is the length for the substring.
First two parameters are mandatory to specify while third one is optional.
So we can say.
SQL Substr function will return a sub string of a specified length from the source string beginning at a given position.
First parameter source string can be of any data type CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB whereas both start_pos, Substr_length parameters must be number data type.
The returning result of SQL Substr function is of same data type of source string.
Let's see an example of SQL Substr function.
SELECT substr('www.RebellionRider.com',5,
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Manish Sharma · Manish Sharma · 16 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
▶
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Oracle Database tutorials 1: How to install Oracle Database 11g on windows 7
Manish Sharma
Oracle Database tutorials 2:How To install SQL Developer on windows 7
Manish Sharma
Oracle Database tutorials 3:How to enable Line numbers in SQL Developer.
Manish Sharma
Oracle Database tutorials 4: database connectivity using SQL developer and command prompt
Manish Sharma
Oracle Database tutorials 5: how to Fetch Data using SELECT - SQL statement by Manish Sharma
Manish Sharma
Oracle Database11g tutorials 6 | | How to use Concatenation operator, character String
Manish Sharma
Oracle Database11g tutorials 7 | |SQL DISTINCT keyword || SQL tutorials
Manish Sharma
Canon EOS 600D 2 lens kit/Canon rebell EOS T3i 2 lens kit Unboxing
Manish Sharma
First look: ORACLE CERTIFIED ASSOCIATE (OCA) CERTIFICATE - ORACLE DATABASE ADMINISTRATOR
Manish Sharma
Oracle Database11g tutorials 8 || SQL DISTINCT with multiple columns |SQL Distinct with Two columns
Manish Sharma
Oracle Database11g tutorials 9 || What is archive log mode and how to enable archive log mode
Manish Sharma
Oracle Database11g tutorials 10 || SQL Single Row Function (SQL Functions )
Manish Sharma
Oracle Database11g tutorials 11: SQL case manipulation function in Oracle Database
Manish Sharma
how to add channel trailer and section on your youtube channel 2014
Manish Sharma
Oracle Database11g tutorials 12 || SQL Concat Function - SQL character manipulation function
Manish Sharma
Oracle Database11g tutorials 13 || SQL substr function / SQL substring function
Manish Sharma
Oracle Database11g tutorials 14 : How to CREATE TABLE using sql developer and command prompt
Manish Sharma
SQL tutorials 15 || How To CREATE TABLE using enterprise manager 11g
Manish Sharma
Oracle Database11g tutorials 16: How to uninstall oracle 11g from windows 7 64 bit
Manish Sharma
ORACLE CERTIFIED PROFESSIONAL(OCP) CERTIFICATE First look - ORACLE DATABASE ADMINISTRATOR
Manish Sharma
Plantronics audio 655 USB headset with Mic Unboxing and Review and Plantronics audio 655 Mic test
Manish Sharma
SQL tutorials 17: SQL Primary Key constraint, Drop primary Key
Manish Sharma
SQL tutorials 18: SQL Foreign Key Constraint By Manish Sharma
Manish Sharma
SQL tutorial 19: ON DELETE SET NULL clause of Foreign Key By Manish Sharma (RebellionRider)
Manish Sharma
SQL tutorials 20: On Delete Cascade Foreign Key By Manish Sharma (RebellionRider)
Manish Sharma
SQL tutorial 21: How To Rename Table in SQL using ALTER TABLE statement By Manish Sharma
Manish Sharma
SQL tutorial 22: How to Add / Delete column from an existing table using alter table
Manish Sharma
SQL tutorial 23: Rename and Modify Column Using Alter Table By Manish Sharma (RebellionRider)
Manish Sharma
SQL tutorial 24 :SQLJoins- Natural Join With ON and USING clause By Manish/Rebellionrider
Manish Sharma
Oracle Database11g tutorials 25: How to install Oracle Database 11g Express Edition R2 on Windows 7
Manish Sharma
SQL tutorial 26: Introduction to SQL Joins in Oracle Database
Manish Sharma
Vidcon 2014 YouTube Fan Funding: How to enable fan funding on YouTube Channel
Manish Sharma
SQL tutorial 27: Right Outer Join in SQL by Manish Sharma for RebellionRider
Manish Sharma
SQL tutorial 28: Left Outer Join By Manish Sharma / RebellionRider
Manish Sharma
SQL tutorial 29: Full Outer Join with example By Manish Sharma/ RebellionRider
Manish Sharma
SQL tutorial 30: Inner Join In SQL by Manish Sharma/RebellionRider
Manish Sharma
SQL tutorial 31 : SQL Cross Join In Oracle Database By Manish Sharma from RebellionRider
Manish Sharma
SQL tutorial 32: How To Insert Data into a Table Using SQL Developer
Manish Sharma
SQL tutorial 33:How To Insert Data into a Table Using SQL INSERT INTO dml statement
Manish Sharma
SQL tutorial 34: How to copy /Insert data into a table from another table using INSERT INTO SELECT
Manish Sharma
SQL tutorial 35: DELETE and TRUNCATE how to delete data from a table
Manish Sharma
SQL tutorial 36: how to create database using database configuration assistant DBCA
Manish Sharma
SQL tutorial 37: How to create NEW USER account using Create User statement in Oracle database
Manish Sharma
SQL tutorial 38: How to create user using SQL Developer in Oracle database
Manish Sharma
SQL tutorial 39: How to create user in oracle using Enterprise Manager
Manish Sharma
SQL tutorial 40: DBA Trick, How to drop a user when it is connected to the database
Manish Sharma
Motorola Moto G 2nd Generation / G2 Unboxing and Review
Manish Sharma
SQL tutorial 41: How to UNLOCK USER in oracle Database
Manish Sharma
SQL tutorial 42: How to Unlock user using SQL Developer By Manish Sharma RebellionRider
Manish Sharma
SQL tutorial 43: How to create an EXTERNAL USER in oracle database By Manish Sharma RebellionRider
Manish Sharma
SQL tutorial 44: How to import data from Microsoft Excel to Oracle Database using SQL Developer
Manish Sharma
SQL tutorial 45: Introduction to user Privileges in Oracle Database By Manish Sharma RebellionRider
Manish Sharma
SQL tutorial 46: What are System Privileges & How To Grant them using Data Control Language
Manish Sharma
SQL tutorial 47: How to Grant Object Privileges With Grant Option in Oracle Database
Manish Sharma
SQL tutorial 48: How to create Roles in Oracle Database
Manish Sharma
SQL tutorial 49: CASE - Simple Case Expression in Oracle Database (1/2)
Manish Sharma
SQL tutorial 50: CASE - Searched Case Expression In Oracle (2/2)
Manish Sharma
SQL tutorial 51: DECODE function in Oracle Database By Manish Sharma (RebellionRider)
Manish Sharma
Oracle Database Tutorial 52 : Data Pump expdp - How to Export full database using expdp
Manish Sharma
Oracle Database Tutorial 53 : Data pump expdp - How to Export tablespace in Oracle Database
Manish Sharma
More on: SQL Analytics
View skill →Related Reads
📰
📰
📰
📰
What I Learned Reading Chapter 1 of “Designing Data-Intensive Applications” (2nd Edition)
Medium · Data Science
Do Countries Really Name Their Streets After the Same Handful of Heroes?
Medium · Python
Filters in Power BI
Dev.to · Seenivasan A
Your Data Is Lying to You (Until You Clean It)
Medium · Data Science
🎓
Tutor Explanation
DeepCamp AI