a.
“LENGTH” function:
- The “LENGTH()” function is used to return the length of a string that is return the number of characters in a given string.
- The syntax for “LENGTH()” function is
LENGTH(string)
- The parameter “string” implies the any string or any column name from specific table.
Example:
The example of “LENGTH()” function is given below:
CREATE TABLE STUDENT_NAMES(Student_ID integer PRIMARY KEY, Name text);
INSERT INTO STUDENT_NAMES VALUES(101,'John');
INSERT INTO STUDENT_NAMES VALUES(201,'Merry');
INSERT INTO STUDENT_NAMES VALUES(301,'Rose');
INSERT INTO STUDENT_NAMES VALUES(401,'Watson');
SELECT Name, LENGTH(Name) AS LengthOfName FROM STUDENT_NAMES;
Explanation:
The above query is used to display the length of each student name from “STUDENT_NAMES” table.
- User can create a table “STUDENT_NAMES” using “CREATE” and then insert the data into “STUDENT_NAMES” table using “INSERT” command.
- Using “SELECT” command, user can display the student name and its length.
- User can compute the length of each student name using “LENGTH” function.
- After that, the computed column is represented by “LengthOfName” with the help of “AS” operator.
When the query “SELECT Name, LENGTH(Name) AS LengthOfName FROM STUDENT_NAMES;” is executed, the following output will be displayed.
| Name | LengthOfName |
|--------|--------------|
| John | 4 |
| Merry | 5 |
| Rose | 4 |
| Watson | 6 |
“SUBSTR” function:
- The “SUBSTR()” function is used to extract a substring from a given string.
- The syntax for “SUBSTR()” function is
SUBSTR(sample_string, start_position, length)
- From the given syntax,
- The parameter “sample_string” implies the any string to extract from.
- The parameter “start_position” implies the starting position of given string.
- The parameter “length” implies number of characters to extract from the given string.
Example:
The example of “SUBSTR()” function is given below:
SELECT SUBSTR("Example SQL Query", 9, 3);
When the above query executed, the following output will be displayed.
Output: SQL
“INITCAP” function:
- The “INITCAP()” function is used to convert the first character of each word in the string to upper case character.
- The syntax for “INITCAP()” function is
INITCAP(sample_string)
- The parameter “sample_string” implies the any string.
Example:
The example of “INITCAP()” function is given below:
SELECT INITCAP('sample
Explanation:
- The above query is used to change the first letter of each word to upper case using “INITCAP” function.
- The computed column that is final result is represented by “Changed Word”.
- From the given query, the “DUAL” is a table which is automatically generated by Oracle
Database along with the data dictionary.- The “DUAL” table contains one column and one row. The column is defined to be “VARCHAR2(1)” and a row with a value “x”.
When the above query is executed, the following output will be displayed.
Output of the given Query:
| Changed String |
|--------------------|
| Sample Programming |
Three functions in Oracle, SQL Server and Access:
- “No”, the three functions are not same in SQL Server and access.
- Reasons for these condition.
- For Oracle:
- The functions “LENGTH”, “SUBSTR” and “INITCAP” are same for the Oracle.
- For SQL server:
- The function “LEN” is used to returns the length of the particular string.
- The “SUBSTRING” function is used to return a substring from a given string.
- The “INITCAP” function is not available in the SQL server.
- For Access:
- The function “LEN” is used to returns the length of the particular string.
- The “MID” function is used to return a substring from a given string.
- The “INITCAP” function is not available in Access.
- For Oracle:
Three functions in Oracle:
“LENGTH” function:
- The “LENGTH()” function is used to return the length of a string that is return the number of characters in a given string.
- The syntax for “LENGTH()” function is
LENGTH(string)
- The parameter “string” implies the any string or any column name from specific table.
Example:
The example of “LENGTH()” function is given below:
SELECT LENGTH('SQL Programming Concept') "Length of Characters" FROM DUAL;
Explanation:
- The above query is used to display the length of character from given string “'SQL Programming Concept” using “LENGTH” function.
- The computed column that is final result is represented by “Length of Characters”.
- From the given query, the “DUAL” is a table which is automatically generated by Oracle Database along with the data dictionary.
- The “DUAL” table contains one column and one row. The column is defined to be “VARCHAR2(1)” and a row with a value “x”.
When the above query is executed, the following output will be displayed.
Output of the given Query:
| Length of Characters |
|----------------------|
| 23 |
“SUBSTR” function:
- The “SUBSTR()” function is used to extract a substring from a given string.
- The syntax for “SUBSTR()” function is
SUBSTR(sample_string, start_position, length)
- From the given syntax,
- The parameter “sample_string” implies the any string to extract from.
- The parameter “start_position” implies the starting position of given string.
- The parameter “length” implies number of characters to extract from the given string.
Example:
The example of “SUBSTR()” function is given below:
SELECT SUBSTR('Example SQLQuery Result', 9, 8) "SubString" FROM DUAL;
Explanation:
- The above query is used to display the substring from the given string “'Example SQLQuery Result” using “SUBSTR” function.
- The computed column that is final result is represented by “SubString”.
- From the given query, the “DUAL” is a table which is automatically generated by Oracle Database along with the data dictionary.
- The “DUAL” table contains one column and one row. The column is defined to be “VARCHAR2(1)” and a row with a value “x”.
When the above query executed, the following output will be displayed.
Output of the given Query:
| SubString |
|-----------|
| SQLQuery |
“INITCAP” function:
- The “INITCAP()” function is used to convert the first character of each word in the string to upper case character.
- The syntax for “INITCAP()” function is
INITCAP(sample_string)
- The parameter “sample_string” implies the any string.
Example:
The example of “INITCAP()” function is given below:
SELECT INITCAP('sample programming') "Changed Word" FROM DUAL;
Explanation:
- The above query is used to change the first letter of each word to upper case using “INITCAP” function.
- The computed column that is final result is represented by “Changed Word”.
- From the given query, the “DUAL” is a table which is automatically generated by Oracle Database along with the data dictionary.
- The “DUAL” table contains one column and one row. The column is defined to be “VARCHAR2(1)” and a row with a value “x”.
When the above query is executed, the following output will be displayed.
Output of the given Query:
| Changed String |
|--------------------|
| Sample Programming |
Three functions in SQL Server:
“LEN” function:
- The “LEN()” function is used to return the length of a string that is return the number of characters in a given string.
- The syntax for “LEN()” function is
LEN(string)
- The parameter “string” implies the any string.
Example:
The example of “LEN()” function is given below:
SELECT LEN('SQL Programming Concept');
Explanation:
- The above query is used to display the length of character from given string “'SQL Programming Concept” using “LEN” function.
When the above query is executed, the following output will be displayed.
Output of the given Query:
23
“SUBSTRING” function:
- The “SUBSTRING()” function is used to extract a substring from a given string.
- The syntax for “SUBSTRING()” function is
SUBSTRING(sample_string, start_position, length)
- From the given syntax,
- The parameter “sample_string” implies the any string to extract from.
- The parameter “start_position” implies the starting position of given string.
- The parameter “length” implies number of characters to extract from the given string.
Example:
The example of “SUBSTR()” function is given below:
SELECT SUBSTRING('Example SQLQuery Result', 9, 8) AS SubString;
Explanation:
- The above query is used to display the substring from the given string “'Example SQLQuery Result” using “SUBSTRING” function.
- The computed column that is final result is represented by “SubString” with the help of “AS” operator.
When the above query executed, the following output will be displayed.
Output of the given Query:
SubString
SQLQuery
“INITCAP” function:
This function is not available in SQL server.
Three functions in Access:
“LEN” function:
- The “LEN()” function is used to return the length of a string that is return the number of characters in a given string.
- The syntax for “LEN()” function is
LEN(string/variable name)
- The parameter “string” implies the any string or any column name from specific table.
Example:
The example of “LEN()” function is given below:
SELECT LEN('SQL Programming Concept') AS Length_Of_String;
Explanation:
- The above query is used to display the length of character from given string “'SQL Programming Concept” using “LEN” function.
- The computed column that is final result is represented by “Length_Of_String” with the help of “AS” operator.
When the above query is executed, the following output will be displayed.
Output of the given Query:
Length_Of_String
23
“MID” function:
- The “MID()” function is used to extract a substring from a given string.
- The syntax for “MID()” function is
MID(sample_string, start_position, length)
- From the given syntax,
- The parameter “sample_string” implies the any string to extract from.
- The parameter “start_position” implies the starting position of given string.
- The parameter “length” implies number of characters to extract from the given string.
Example:
The example of “MID()” function is given below:
CREATE TABLE STUDENT_NAMES(Student_ID integer PRIMARY KEY, Name text);
INSERT INTO STUDENT_NAMES VALUES(301,'John Merry');
INSERT INTO STUDENT_NAMES VALUES(401,'Rose Lilly');
SELECT Name, MID(STUDENT_NAMES, 6, 5) AS SubString_Names FROM STUDENT_NAMES;
Explanation:
The above query is used to display the sub string each student name from “STUDENT_NAMES” table.
- User can create a table “STUDENT_NAMES” using “CREATE” and then insert the data into “STUDENT_NAMES” table using “INSERT” command.
- Using “SELECT” command, user can display the student name and its length.
- User can compute the sub string of each student name using “MID” function.
- After that, the computed column is represented by “SubString_Names” with the help of “AS” operator.
When the above query executed, the following output will be displayed.
Output of the given Query:
SubString_Names
Merry
Lilly
“INITCAP” function:
This function is not available in access.

Explanation of Solution
Oracle SQL query to display characters from the “TYPE” column in the “TRIP” table:
The Oracle SQL query to display three characters on the left from the “TYPE” column of the “TRIP” table is given below:
SELECT SUBSTR(TYPE,0,3) "SubString from TYPE Column" FROM TRIP;
Explanation:
The above query is used to display three characters on the left from the “TYPE” column of the “TRIP” table.
- Using “SUBSTR” function, user can display the three characters on the left from the “TYPE” column with three arguments “TYPE” column, start position “0” and number of character to extract “3”.
- The computed column is represented by “SubString from TYPE Column”.
- When the above query is executed, the following output will be displayed.
Screenshot of output:
Explanation of Solution
Oracle SQL query to display characters from the “START_LOCATION” column of the “TRIP” table:
The Oracle and SQL query for starting at the fourth character from the left, display the next five characters in the “START_LOCATION” column of the “TRIP” table is given below:
SELECT SUBSTR(START_LOCATION,4,5) "SubString of START_LOCATION" FROM TRIP;
Explanation:
The above query is used to display the given characters from “START_LOCATION” column of the “TRIP” table.
- Using “SUBSTR” function, user can display the given characters from the “START_LOCATION” column with three arguments “START_LOCATION” column, start position “3” and number of character to extract “5”.
- The computed column is represented by “SubString of START_LOCATION”.
- When the above query is executed, the following output will be displayed.

Screenshot of output:
Want to see more full solutions like this?
Chapter 8 Solutions
A GUIDE TO SQL
- Design a dynamic programming algorithm for the problem described below Input: A list of numbers A = = [a1,..., an]. Output: A contiguous subsequence of numbers with the maximum sum. The algorithm must take O(n) time. You must also write and explain the recurrence. (I am looking for an i ≥ 1 and k ≥ 0 such that a + ai+1 + ···ai+k has the largest possible sum among all possible values for i and k.) Example 1: Input: A[5, 15, -30, 10, -5, 40, 10]. Output: [10, 5, 40, 10] Example 2: Input: A = [7, 5, 7, 4, -20, 6, 9, 3, -4, -8, 4] Output: [6,9,3]arrow_forwardDesign a dynamic programming algorithm for the Longest Increasing Subsequence problem described below: Input: A sequence of n integers Output: The length of the longest increasing subsequence among these integers. The algorithm must take O(n²) time. You must also write and explain the recurrence. Example 1: Input: [5, 3, 6, 8, 4, 6, 2, 7, 9, 5] Output: 5 ([3, 4, 6, 7, 9]) Example 2: Input: [12, 42, 66, 73, 234, 7, 543, 16] Output: 6 ([42, 66, 73, 234, 543])arrow_forwardDesign a dynamic programming algorithm for the Subset Sum problem described below: Input: A set of n integers A and an integer s Output: A subset of A whose numbers add up to s, or that no such set exists. The algorithm must take O(n·s) time. You must also write and explain the recurrence. Example 1: Input: A = {4, 7, 5, 2, 3}, s = 12 Output: {7,2,3} Example 2: Input: A{4, 7, 5,3}, s = 6 Output: 'no such subset'arrow_forward
- TECNOLOGIE DEL WEB 2023/2023 (VER 1.1) Prof. Alfonso Pierantonio 1. Project Requirements The project consists in designing and implementing a Web application according to the methodology and the technologies illustrated and developed during the course. This document describe cross-cutting requirements the application must satisfy. The application must be realized with a combination of the following technologies: PHP MySQL HTML/CSS JavaScript, jQuery, etc templating The requirements are 2. Project size The application must have at least 18 SQL tables The number of SQL tables refers to the overall number of tables (including relation normalizations). 3. Methodology The application must be realized by adopting separation of logics, session management, and generic user management (authentication/permissions). Missing one of the above might correspond to a non sufficient score for the project. More in details: 3.1 Separation of Logics The separation of logics has to be realizse by using…arrow_forwardWrite a C program to calculate the function sin(x) or cos(x) using a Taylor series expansion around the point 0. In other words, you will program the sine or cosine function yourself, without using any existing solution. You can enter the angles in degrees or radians. The program must work for any input, e.g. -4500° or +8649°. The function will have two arguments: float sinus(float radians, float epsilon); For your own implementation, use one of the following relations (you only need to program either sine or cosine, you don't need both): Tip 1: Of course, you cannot calculate the sum of an infinite series indefinitely. You can see (if not, look in the program) that the terms keep getting smaller, so there will definitely be a situation where adding another term will not change the result in any way (see problem 1.3 – machine epsilon). However, you can end the calculation even earlier – when the result changes by less than epsilon (a pre-specified, sufficiently small number, e.g.…arrow_forwardWrite a C program that counts the number of ones (set bits) in the binary representation of a given number. Example:Input: 13 (binary 1101)Output: 3 unitsarrow_forward
- I need help to resolve or draw the diagrams. thank youarrow_forwardYou were requested to design IP addresses for the following network using the addressblock 166.118.10.0/8, connected to Internet with interface 168.118.40.17 served by the serviceprovider with router 168.118.40.1/20.a) Specify an address and net mask for each network and router interface in the table provided. b) Give the routing table at Router 1.c) How will Router 1 route the packets with destinationi) 168.118.10.5ii) 168.118.10.103iii) 168.119.10.31iii) 168.118.10.153arrow_forwardI would like to get help to draw an object relationship diagram for a typical library system.arrow_forward
- Given the network of bridges in figure, and assuming that LAN ports on A, B, C, D, E, J are 10 Mbs (cost 100 for ports) except for ports on F, G, I, H, K which are 100Mbps LANs (cost 19 for ports) Draw the obtained spanning tree, cross the blocking state ports, and circle the designated ports and write the best cost broadcasted by each router next to its root port. list in logic level detail the expected last STP messages that will define the final status at each router.arrow_forwardNext, you are going to combine everything you've learned about HTML and CSS to make a static site portfolio piece. The page should first introduce yourself. The content is up to you, but should include a variety of HTML elements, not just text. This should be followed by an online (HTML-ified) version of your CV (Resume). The following is a minimum list of requirements you should have across all your content: Both pages should start with a CSS reset (imported into your CSS, not included in your HTML) Semantic use of HTML5 sectioning elements for page structure A variety other semantic HTML elements Meaningful use of Grid, Flexbox and the Box Model as appropriate for different layout components A table An image Good use of CSS Custom Properties (variables) Non-trivial use of CSS animation Use of pseudeo elements An accessible colour palette Use of media queries The focus of this course is development, not design. However, being able to replicate a provided design for the web is…arrow_forwardI would like to get help to draw an object relationship diagram for a typical library system.arrow_forward
- A Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology PtrDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781305627482Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781285196145Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos CoronelPublisher:Cengage Learning



