SlideShare a Scribd company logo
1 of 19
Download to read offline
1
RDBMS with MYSQL_1
BT0075 Part -1
By Milan K Antony
2
Mention 4 features of MySQL.
Security:
· A privilege and password system that is very flexible and secure,
and that allows host-based verification.
· Passwords are secure because all password traffic is encrypted when
you connect to a server.
Scalability and Limits:
· Handles large databases. We use MySQL Server with databases that
contain 50 million records. We also know of users who use MySQL
Server with 60,000 tables and about 5,000,000,000 rows.
· Up to 64 indexes per table are allowed (32 before MySQL 4.1.2).
Each index may consist of 1 to 16 columns or parts of columns. The
maximum index width is 1000 bytes (767 for InnoDB); before MySQL
4.1.2, the limit is 500 bytes. An index may use a prefix of a column
for CHAR, VARCHAR, BLOB, or TEXT column types.
Connectivity:
· Clients can connect to MySQL Server using several protocols:
3
- Clients can connect using TCP/IP sockets on any platform.
- On Windows systems in the NT family (NT, 2000, XP, 2003, or
Vista), clients can connect using named pipes if the server is started
with the – enable-named-pipe option. In MySQL 4.1 and higher,
Windows servers also support shared-memory connections if started
with the – shared-memory option. Clients can connect through shared
memory by using the – protocol=memory option.
- On Unix systems, clients can connect using Unix domain socket files.
· MySQL client programs can be written in many languages. A client
library written in C is available for clients written in C or C++, or
for any language that provides C bindings.
· APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and Tcl
are available, allowing MySQL clients to be written in many languages.
· The Connector/ODBC (MyODBC) interface provides MySQL support
for client programs that use ODBC (Open Database Connectivity)
connections.
For example, you can use MS Access to connect to your MySQL
server. Clients can be run on Windows or Unix. MyODBC source is
available. All ODBC 2.5 functions are supported, as are many others.
· The Connector/J interface provides MySQL support for Java client
programs that use JDBC connections. Clients can be run on Windows
or Unix. Connector/J source is available.
· MySQL Connector/NET enables developers to easily create .NET
applications that require secure, high-performance data connectivity
with MySQL. It implements the required ADO.NET interfaces and
4
integrates into ADO.NET aware tools. Developers can build
applications using their choice of .NET languages. MySQL
Connector/NET is a fully managed ADO.NET driver written in 100%
pure C#.
Localization:
· The server can provide error messages to clients in many languages.
· Full support for several different character sets, including latin1
(cp1252), german, big5, ujis, and more. For example, the
Scandinavian characters “å”, “ä” and “ö” are allowed in table and column
names. Unicode support is available as of MySQL 4.1.
· All data is saved in the chosen character set.
· Sorting and comparisons are done according to the chosen character
set and collation (using latin1 and Swedish collation by default). It is
possible to change this when the MySQL server is started. To see an
example of very advanced sorting, look at the Czech sorting code.
MySQL Server supports many different character sets that can be
specified at compile time and runtime.
· As of MySQL 4.1, the server time zone can be changed dynamically,
and individual clients can specify their own time zone.
5
2. Write the differences between char and varchar data types in
MySQL.
The CHAR and VARCHAR types are similar, but differ in the
way they are stored and retrieved. They also differ in maximum
length and in whether trailing spaces are retained.
The CHAR and VARCHAR types are declared with a length that
indicates the maximum number of characters you want to store. For
example, CHAR(30) can hold up to 30 characters.
The length of a CHAR column is fixed to the length that you declare
when you create the table. The length can be any value from 0 to
255. When CHAR values are stored, they are right-padded with spaces
to the specified length. When CHAR values are retrieved, trailing
spaces are removed unless the PAD_CHAR_TO_FULL_LENGTH SQL mode
is enabled.
6
Values in VARCHAR columns are variable-length strings. The length
can be specified as a value from 0 to 65,535. The effective maximum
length of a VARCHAR is subject to the maximum row size (65,535
bytes, which is shared among all columns) and the character set used.
In contrast to CHAR, VARCHAR values are stored as a one-byte or
two-byte length prefix plus data. The length prefix indicates the
number of bytes in the value. A column uses one length byte if
values require no more than 255 bytes, two length bytes if values may
require more than 255 bytes.
If strict SQL mode is not enabled and you assign a value to a CHAR
or VARCHAR column that exceeds the column’s maximum length, the
value is truncated to fit and a warning is generated. For truncation
of non-space characters, you can cause an error to occur (rather
than a warning) and suppress insertion of the value by using strict
SQL mode.
For VARCHAR columns, trailing spaces in excess of the column length
are truncated prior to insertion and a warning is generated,
regardless of the SQL mode in use. For CHAR columns, truncation of
excess trailing spaces from inserted values is performed silently
regardless of the SQL mode.
VARCHAR values are not padded when they are stored. Trailing spaces
are retained when values are stored and retrieved, in conformance
with standard SQL.
7
3. Write about the operations supported by indexes in MySQL.
Indexes are used to find rows with specific column values quickly.
Without an index, MySQL must begin with the first row and then read
through the entire table to find the relevant rows. The larger the
table, the more is the cost. If the table has an index for the
columns in question, MySQL can quickly determine the position to seek
to in the middle of the data file without having to look at all the
data. If a table has 1,000 rows, this is at least 100 times faster than
reading sequentially. If you need to access most of the rows, it is
faster to read sequentially, because this minimizes disk seeks. If a
multiple-column index exists on col1 and col2, the appropriate rows
can be fetched directly. If separate single-column indexes exist on
col1 and col2, the optimizer will attempt to use the Index Merge
optimization, or attempt to find the most restrictive index by
deciding which index finds fewer rows and using that index to fetch
the rows.
Index Merge optimization: The Index Merge method is used to
retrieve rows with several range scans and to merge their results into
one. The merge can produce unions, intersections, or unions-of-
intersections of its underlying scans. This access method merges index
scans from a single table; it does not merge scans across multiple
tables.MySQL uses indexes for these operations:
· To find the rows matching a WHERE clause quickly.
8
· To eliminate rows from consideration. If there is a choice between
multiple indexes, MySQL normally uses the index that finds the smallest
number of rows.
· To retrieve rows from other tables when performing joins. MySQL
can use indexes on columns more efficiently if they are declared as
the same type and size. In this context, VARCHAR and CHAR are
considered the same if they are declared as the same size. For
example, VARCHAR(10) and CHAR(10) are the same size, but
VARCHAR(10) and CHAR(15) are not.
Comparison of dissimilar columns may prevent use of indexes if values
cannot be compared directly without conversion. Suppose that a
numeric column is compared to a string column. For a given value
such as 1 in the numeric column, it might compare equal to any
number of values in the string column such as '1', ' 1', '00001', or
'01.e1'. This rules out use of any indexes for the string column.
· To find the MIN() or MAX() value for a specific indexed column
key_col. This is optimized by a preprocessor that checks whether you
are using WHERE key_part_N = constant on all key parts that occur
before key_col in the index. In this case, MySQL does a single key
lookup for each MIN() or MAX() expression and replaces it with a
constant. If all expressions are replaced with constants, the query
returns at once.
9
4. Write the SQL statements to demonstrate the following using
SELECT command:
a. Expression Evaluation
10
b. Using table aliases
c. ORDER BY
5. Define the following types of Joins:
a. Inner Join
they are also known as Equi Joins. They are so called because
the where statement generally compares two columns from two tables
with the equivalence operator =. Many systems use this type as the
default join. This type can be used in situations where selecting only
11
those rows that have values in common in the columns specified in the
ON clause, is required. In short, the Inner Join returns all rows from
both tables where there is a match.
mysql> SELECT ProdName, Quantity FROM Products, Sales WHERE
Products.ProdID = Sales.ProdID AND Sales.Quantity > 2000;
b. Left Outer Join
In this type, all the records from the table on the left
side of the join and matching the WHERE clause in appear in the final
result set.
mysql> SELECT * FROM users LEFT JOIN users_groups ON
users.uid = users_groups.uid;
c. Right Outer Join
All the records matching the WHERE clause from the table
on the right appear.
mysql> SELECT * FROM users_groups RIGHT JOIN groups USING
(gid);
12
6. Give the advantages of subqueries.
A Subquery is exactly what it sounds like: a SELECT query that is
subordinate to another query. This unit covers the various concepts
of subqueries.
1. The subquery as scalar operand: A scalar subquery is a simple
operand, and you can use it almost anywhere a single column value or
literal is legal, and you can expect it to have those characteristics
that all operands have: a data type, a length, an indication whether it
can be NULL, and so on.
2. Comparisons Using Subqueries: The output of the subqueries can
be used to compare the output of the outer most queries. This can
be done using various comparison operators like >, <, IN, and so on.
3. Subqueries with ANY, IN, and SOME: These type of subqueries
can be used in cases where a set of values need to be compared and
the output determined.
13
4. Subqueries with ALL: These type of subqueries can be used in
cases where a set of values are the output generated by the inner or
subqueries and the output is possible only if all the values match with
the outer query.
5. Correlated Subqueries: Sometimes a situation arises in which a
subquery uses a field from the main query in its clause. Such a
reference by a subquery to a field in its enclosing query, is called an
outer reference, and the corresponding subquery is called a
correlated subquery, because it’s correlated with the result set of one
or more of the queries enclosing it.
6. EXISTS and NOT EXISTS: The Exists operator can be used to
check if a subquery produces any results at all. The NOT EXISTS
operator is exactly the opposite of the output produced by NOT
EXISTS.
7. Row Subqueries: A row subquery is a subquery variant that returns
a single row and can thus return more than one column value.
7. Subqueries in the FROM Clause: Subqueries are legal in a
14
SELECT statement’s FROM clause. Any columns in the subquery
select list must have unique names.
7. Discuss any five string functions.
String-valued functions return NULL if the length of the result
would be greater than the value of the max_allowed_packet system
variable. For functions that operate on string positions, the first
position is numbered 1.
1,ASCII(str)-Returns the numeric value of the leftmost character of
the string str. Returns 0 if str is the empty string. Returns NULL if
str is NULL. ASCII() works for characters with numeric values from 0
to 255.1. SELECT ASCII(’2 );′
2,BIN(N)-Returns a string representation of the binary value of N,
where N is a longlong (BIGINT) number. SELECT BIN(12);
3,BIT_LENGTH(str)-Returns the length of the string str in
bits.SELECT BIT_LENGTH(’text’);
4,CHAR(N,…)--CHAR() interprets the arguments as integers and
returns a string consisting of the characters given by the code values
15
of those integers. NULL values are skipped.1.SELECT
CHAR(77,121,83,81,’76 );SELECT INSERT(’Quadratic’, 3, 4, ‘What’);′
5,INSERT(str,pos,len,newstr)--Returns the string str, with the
substring beginning at position pos and len characters long replaced
by the string newstr.
8. Describe the operators that support the boolean full-text
searches.
MySQL can perform boolean full-text searches using the IN
BOOLEAN MODE modifier:· +: A leading plus sign indicates that this
word must be present in each row that is returned.
· -: A leading minus sign indicates that this word must not be
present in any of the rows that are returned.
Note: The – operator acts only to exclude rows that are otherwise
matched by other search terms. Thus, a boolean-mode search that
contains only terms preceded by – returns an empty result. It does
not return “all rows except those containing any of the excluded
16
terms.”
· (no operator): By default (when neither + nor – is specified) the
word is optional, but the rows that contain it are rated higher. This
mimics the behavior of MATCH() … AGAINST() without the IN
BOOLEAN MODE modifier.
· > <: These two operators are used to change a word’s contribution
to the relevance value that is assigned to a row. The > operator
increases the contribution and the < operator decreases it.
· ( ): Parentheses group words into subexpressions. Parenthesized
groups can be nested.
· ~: A leading tilde acts as a negation operator, causing the word's
contribution to the row's relevance to be negative. This is useful for
marking “noise” words. A row containing such a word is rated lower
than others, but is not excluded altogether, as it would be with the
- operator.
· *: The asterisk serves as the truncation (or wildcard) operator.
Unlike the other operators, it should be appended to the word to be
affected. Words match if they begin with the word preceding the *
17
operator.
If a stopword or too-short word is specified with the truncation
operator, it will not be stripped from a boolean query. For example,
a search for '+word +stopword*' will likely return fewer rows than a
search for '+word +stopword' because the former query remains as is
and requires stopword* to be present in a document. The latter
query is transformed to +word.
· ": A phrase that is enclosed within double quote (“"”) characters
matches only rows that contain the phrase literally, as it was typed.
The full-text engine splits the phrase into words, performs a search
in the FULLTEXT index for the words. Non-word characters need not
be matched exactly: Phrase searching requires only that matches
contain exactly the same words as the phrase and in the same order.
9. Describe the Savepoint and Rollback to Savepoint Syntaxes.
18
Starting from MySQL 4.0.14 and 4.1.1, InnoDB supports the SQL
statements SAVEPOINT and ROLLBACK TO SAVEPOINT.
The SAVEPOINT statement sets a named transaction savepoint with a
name of identifier. If the current transaction already has a savepoint
with the same name, the old savepoint is deleted and a new one is
set.
The ROLLBACK TO SAVEPOINT statement rolls back a transaction to
the named savepoint. Modifications that the current transaction made
to rows after the savepoint was set are undone in the rollback, but
InnoDB does not release the row locks that were stored in memory
after the savepoint. (Note that for a new inserted row, the lock
information is carried by the transaction ID stored in the row; the
lock is not separately stored in memory. In this case, the row lock is
released in the undo.) Savepoints that were set at a later time than
the named savepoint are deleted.
10.Give the syntax of BEGIN…END compound statement.
19
Stored routines may contain multiple statements, using a BEGIN … END
compound statement. begin_label and end_label must be the same, if
both are specified. Please note that the optional [NOT] ATOMIC clause
is not yet supported. This means that no transactional savepoint is set
at the start of the instruction block and the BEGIN clause used in
this context has no effect on the current transaction.
Multiple statements requires that a client is able to send query strings
containing ‘;’. This is handled in the mysql command-line client with
the delimiter command. Changing the ‘;’ end-of-query delimiter (for
example, to ‘|’) allows ‘;’ to be used in a routine body.

More Related Content

What's hot (19)

Join query
Join queryJoin query
Join query
 
Working with designers
Working with designersWorking with designers
Working with designers
 
Fg d
Fg dFg d
Fg d
 
SQL JOIN
SQL JOINSQL JOIN
SQL JOIN
 
SQL Joins
SQL JoinsSQL Joins
SQL Joins
 
Sql joins
Sql joinsSql joins
Sql joins
 
Sql join
Sql  joinSql  join
Sql join
 
Optimized cluster index generation
Optimized cluster index generationOptimized cluster index generation
Optimized cluster index generation
 
Sql wksht-7
Sql wksht-7Sql wksht-7
Sql wksht-7
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer join
 
Index in sql server
Index in sql serverIndex in sql server
Index in sql server
 
Sql interview q&a
Sql interview q&aSql interview q&a
Sql interview q&a
 
joins and subqueries in big data analysis
joins and subqueries in big data analysisjoins and subqueries in big data analysis
joins and subqueries in big data analysis
 
SQL Joinning.Database
SQL Joinning.DatabaseSQL Joinning.Database
SQL Joinning.Database
 
Sql ch 1
Sql ch 1Sql ch 1
Sql ch 1
 
Sql joins
Sql joinsSql joins
Sql joins
 
Sql joins
Sql joinsSql joins
Sql joins
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
 
SQL
SQLSQL
SQL
 

Viewers also liked

Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Techglyphs
 
Bt0066 database management system2
Bt0066 database management system2Bt0066 database management system2
Bt0066 database management system2Techglyphs
 
Social media new uma1roopa
Social media new uma1roopaSocial media new uma1roopa
Social media new uma1roopaRoopa slideshare
 
Bt0084 technical communications 2
Bt0084 technical communications 2Bt0084 technical communications 2
Bt0084 technical communications 2Techglyphs
 
Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1Techglyphs
 
Bt0072 computer networks 2
Bt0072 computer networks  2Bt0072 computer networks  2
Bt0072 computer networks 2Techglyphs
 
Bt0081 software engineering
Bt0081 software engineeringBt0081 software engineering
Bt0081 software engineeringTechglyphs
 
Bt0087 wml and wap programing2
Bt0087 wml and wap programing2Bt0087 wml and wap programing2
Bt0087 wml and wap programing2Techglyphs
 
Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Techglyphs
 
Bt0084 technical communications 1
Bt0084 technical communications 1Bt0084 technical communications 1
Bt0084 technical communications 1Techglyphs
 
Bt0070 operating systems 1
Bt0070 operating systems  1Bt0070 operating systems  1
Bt0070 operating systems 1Techglyphs
 
Bt0075 rdbms with mysql 2
Bt0075 rdbms with mysql 2Bt0075 rdbms with mysql 2
Bt0075 rdbms with mysql 2Techglyphs
 
Bt0072 computer networks 1
Bt0072 computer networks  1Bt0072 computer networks  1
Bt0072 computer networks 1Techglyphs
 
Bt0083 server side programing 2
Bt0083 server side programing  2Bt0083 server side programing  2
Bt0083 server side programing 2Techglyphs
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing Techglyphs
 
Bt9002 Grid computing 2
Bt9002 Grid computing 2Bt9002 Grid computing 2
Bt9002 Grid computing 2Techglyphs
 
Bt0088 cryptography and network security2
Bt0088 cryptography and network security2Bt0088 cryptography and network security2
Bt0088 cryptography and network security2Techglyphs
 
Bt0066 database management system1
Bt0066 database management system1Bt0066 database management system1
Bt0066 database management system1Techglyphs
 
Bt0077 multimedia systems
Bt0077 multimedia systemsBt0077 multimedia systems
Bt0077 multimedia systemsTechglyphs
 
Bt0088 cryptography and network security1
Bt0088 cryptography and network security1Bt0088 cryptography and network security1
Bt0088 cryptography and network security1Techglyphs
 

Viewers also liked (20)

Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1
 
Bt0066 database management system2
Bt0066 database management system2Bt0066 database management system2
Bt0066 database management system2
 
Social media new uma1roopa
Social media new uma1roopaSocial media new uma1roopa
Social media new uma1roopa
 
Bt0084 technical communications 2
Bt0084 technical communications 2Bt0084 technical communications 2
Bt0084 technical communications 2
 
Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1
 
Bt0072 computer networks 2
Bt0072 computer networks  2Bt0072 computer networks  2
Bt0072 computer networks 2
 
Bt0081 software engineering
Bt0081 software engineeringBt0081 software engineering
Bt0081 software engineering
 
Bt0087 wml and wap programing2
Bt0087 wml and wap programing2Bt0087 wml and wap programing2
Bt0087 wml and wap programing2
 
Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Bt0067 c programming and data structures2
Bt0067 c programming and data structures2
 
Bt0084 technical communications 1
Bt0084 technical communications 1Bt0084 technical communications 1
Bt0084 technical communications 1
 
Bt0070 operating systems 1
Bt0070 operating systems  1Bt0070 operating systems  1
Bt0070 operating systems 1
 
Bt0075 rdbms with mysql 2
Bt0075 rdbms with mysql 2Bt0075 rdbms with mysql 2
Bt0075 rdbms with mysql 2
 
Bt0072 computer networks 1
Bt0072 computer networks  1Bt0072 computer networks  1
Bt0072 computer networks 1
 
Bt0083 server side programing 2
Bt0083 server side programing  2Bt0083 server side programing  2
Bt0083 server side programing 2
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing
 
Bt9002 Grid computing 2
Bt9002 Grid computing 2Bt9002 Grid computing 2
Bt9002 Grid computing 2
 
Bt0088 cryptography and network security2
Bt0088 cryptography and network security2Bt0088 cryptography and network security2
Bt0088 cryptography and network security2
 
Bt0066 database management system1
Bt0066 database management system1Bt0066 database management system1
Bt0066 database management system1
 
Bt0077 multimedia systems
Bt0077 multimedia systemsBt0077 multimedia systems
Bt0077 multimedia systems
 
Bt0088 cryptography and network security1
Bt0088 cryptography and network security1Bt0088 cryptography and network security1
Bt0088 cryptography and network security1
 

Similar to Bt0075 rdbms with mysql 1

SQL Interview Questions For Experienced
SQL Interview Questions For ExperiencedSQL Interview Questions For Experienced
SQL Interview Questions For Experiencedzynofustechnology
 
Cassandra Tutorial | Data types | Why Cassandra for Big Data
 Cassandra Tutorial | Data types | Why Cassandra for Big Data Cassandra Tutorial | Data types | Why Cassandra for Big Data
Cassandra Tutorial | Data types | Why Cassandra for Big Datavinayiqbusiness
 
Apache Cassandra, part 1 – principles, data model
Apache Cassandra, part 1 – principles, data modelApache Cassandra, part 1 – principles, data model
Apache Cassandra, part 1 – principles, data modelAndrey Lomakin
 
Presentation1
Presentation1Presentation1
Presentation1Jay Patel
 
Anchor data type,cursor data type,array data type
Anchor data type,cursor data type,array data typeAnchor data type,cursor data type,array data type
Anchor data type,cursor data type,array data typedhruv patel
 
White paper on cassandra
White paper on cassandraWhite paper on cassandra
White paper on cassandraNavanit Katiyar
 
My sql technical reference manual
My sql technical reference manualMy sql technical reference manual
My sql technical reference manualMir Majid
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsDave Stokes
 
My sql università di enna a.a. 2005-06
My sql   università di enna a.a. 2005-06My sql   università di enna a.a. 2005-06
My sql università di enna a.a. 2005-06YUCHENG HU
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfDraguClaudiu
 

Similar to Bt0075 rdbms with mysql 1 (20)

SQL Interview Questions For Experienced
SQL Interview Questions For ExperiencedSQL Interview Questions For Experienced
SQL Interview Questions For Experienced
 
Mysql Optimization
Mysql OptimizationMysql Optimization
Mysql Optimization
 
Cassandra Tutorial | Data types | Why Cassandra for Big Data
 Cassandra Tutorial | Data types | Why Cassandra for Big Data Cassandra Tutorial | Data types | Why Cassandra for Big Data
Cassandra Tutorial | Data types | Why Cassandra for Big Data
 
Viva voce
Viva voceViva voce
Viva voce
 
Introduction to my_sql
Introduction to my_sqlIntroduction to my_sql
Introduction to my_sql
 
Sql
SqlSql
Sql
 
2017 biological databasespart2
2017 biological databasespart22017 biological databasespart2
2017 biological databasespart2
 
Apache Cassandra, part 1 – principles, data model
Apache Cassandra, part 1 – principles, data modelApache Cassandra, part 1 – principles, data model
Apache Cassandra, part 1 – principles, data model
 
2016 02 23_biological_databases_part2
2016 02 23_biological_databases_part22016 02 23_biological_databases_part2
2016 02 23_biological_databases_part2
 
Presentation1
Presentation1Presentation1
Presentation1
 
Anchor data type,cursor data type,array data type
Anchor data type,cursor data type,array data typeAnchor data type,cursor data type,array data type
Anchor data type,cursor data type,array data type
 
Adbms
AdbmsAdbms
Adbms
 
White paper on cassandra
White paper on cassandraWhite paper on cassandra
White paper on cassandra
 
Optimizing MySQL queries
Optimizing MySQL queriesOptimizing MySQL queries
Optimizing MySQL queries
 
sql.pdf
sql.pdfsql.pdf
sql.pdf
 
My sql technical reference manual
My sql technical reference manualMy sql technical reference manual
My sql technical reference manual
 
Cassandra Learning
Cassandra LearningCassandra Learning
Cassandra Learning
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query Optimizations
 
My sql università di enna a.a. 2005-06
My sql   università di enna a.a. 2005-06My sql   università di enna a.a. 2005-06
My sql università di enna a.a. 2005-06
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
 

More from Techglyphs

Bt9002 grid computing 1
Bt9002 grid computing 1Bt9002 grid computing 1
Bt9002 grid computing 1Techglyphs
 
Bt8901 objective oriented systems2
Bt8901 objective oriented systems2Bt8901 objective oriented systems2
Bt8901 objective oriented systems2Techglyphs
 
Bt0062 fundamentals of it(1)
Bt0062 fundamentals of it(1)Bt0062 fundamentals of it(1)
Bt0062 fundamentals of it(1)Techglyphs
 
Bt0062 fundamentals of it(2)
Bt0062 fundamentals of it(2)Bt0062 fundamentals of it(2)
Bt0062 fundamentals of it(2)Techglyphs
 
Bt0064 logic design1
Bt0064 logic design1Bt0064 logic design1
Bt0064 logic design1Techglyphs
 
Bt0064 logic design2
Bt0064 logic design2Bt0064 logic design2
Bt0064 logic design2Techglyphs
 
Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1Techglyphs
 
Bt0068 computer organization and architecture
Bt0068 computer organization and architecture Bt0068 computer organization and architecture
Bt0068 computer organization and architecture Techglyphs
 
Bt0068 computer organization and architecture 2
Bt0068 computer organization and architecture 2Bt0068 computer organization and architecture 2
Bt0068 computer organization and architecture 2Techglyphs
 
Bt0070 operating systems 2
Bt0070 operating systems  2Bt0070 operating systems  2
Bt0070 operating systems 2Techglyphs
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2Techglyphs
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with javaTechglyphs
 
Bt0078 website design
Bt0078 website design Bt0078 website design
Bt0078 website design Techglyphs
 
Bt0077 multimedia systems2
Bt0077 multimedia systems2Bt0077 multimedia systems2
Bt0077 multimedia systems2Techglyphs
 
Bt0078 website design 2
Bt0078 website design 2Bt0078 website design 2
Bt0078 website design 2Techglyphs
 
Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2Techglyphs
 
Bt0082 visual basic2
Bt0082 visual basic2Bt0082 visual basic2
Bt0082 visual basic2Techglyphs
 
Bt0081 software engineering2
Bt0081 software engineering2Bt0081 software engineering2
Bt0081 software engineering2Techglyphs
 
Bt0082 visual basic
Bt0082 visual basicBt0082 visual basic
Bt0082 visual basicTechglyphs
 

More from Techglyphs (19)

Bt9002 grid computing 1
Bt9002 grid computing 1Bt9002 grid computing 1
Bt9002 grid computing 1
 
Bt8901 objective oriented systems2
Bt8901 objective oriented systems2Bt8901 objective oriented systems2
Bt8901 objective oriented systems2
 
Bt0062 fundamentals of it(1)
Bt0062 fundamentals of it(1)Bt0062 fundamentals of it(1)
Bt0062 fundamentals of it(1)
 
Bt0062 fundamentals of it(2)
Bt0062 fundamentals of it(2)Bt0062 fundamentals of it(2)
Bt0062 fundamentals of it(2)
 
Bt0064 logic design1
Bt0064 logic design1Bt0064 logic design1
Bt0064 logic design1
 
Bt0064 logic design2
Bt0064 logic design2Bt0064 logic design2
Bt0064 logic design2
 
Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1
 
Bt0068 computer organization and architecture
Bt0068 computer organization and architecture Bt0068 computer organization and architecture
Bt0068 computer organization and architecture
 
Bt0068 computer organization and architecture 2
Bt0068 computer organization and architecture 2Bt0068 computer organization and architecture 2
Bt0068 computer organization and architecture 2
 
Bt0070 operating systems 2
Bt0070 operating systems  2Bt0070 operating systems  2
Bt0070 operating systems 2
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with java
 
Bt0078 website design
Bt0078 website design Bt0078 website design
Bt0078 website design
 
Bt0077 multimedia systems2
Bt0077 multimedia systems2Bt0077 multimedia systems2
Bt0077 multimedia systems2
 
Bt0078 website design 2
Bt0078 website design 2Bt0078 website design 2
Bt0078 website design 2
 
Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2
 
Bt0082 visual basic2
Bt0082 visual basic2Bt0082 visual basic2
Bt0082 visual basic2
 
Bt0081 software engineering2
Bt0081 software engineering2Bt0081 software engineering2
Bt0081 software engineering2
 
Bt0082 visual basic
Bt0082 visual basicBt0082 visual basic
Bt0082 visual basic
 

Recently uploaded

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 

Recently uploaded (20)

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 

Bt0075 rdbms with mysql 1

  • 1. 1 RDBMS with MYSQL_1 BT0075 Part -1 By Milan K Antony
  • 2. 2 Mention 4 features of MySQL. Security: · A privilege and password system that is very flexible and secure, and that allows host-based verification. · Passwords are secure because all password traffic is encrypted when you connect to a server. Scalability and Limits: · Handles large databases. We use MySQL Server with databases that contain 50 million records. We also know of users who use MySQL Server with 60,000 tables and about 5,000,000,000 rows. · Up to 64 indexes per table are allowed (32 before MySQL 4.1.2). Each index may consist of 1 to 16 columns or parts of columns. The maximum index width is 1000 bytes (767 for InnoDB); before MySQL 4.1.2, the limit is 500 bytes. An index may use a prefix of a column for CHAR, VARCHAR, BLOB, or TEXT column types. Connectivity: · Clients can connect to MySQL Server using several protocols:
  • 3. 3 - Clients can connect using TCP/IP sockets on any platform. - On Windows systems in the NT family (NT, 2000, XP, 2003, or Vista), clients can connect using named pipes if the server is started with the – enable-named-pipe option. In MySQL 4.1 and higher, Windows servers also support shared-memory connections if started with the – shared-memory option. Clients can connect through shared memory by using the – protocol=memory option. - On Unix systems, clients can connect using Unix domain socket files. · MySQL client programs can be written in many languages. A client library written in C is available for clients written in C or C++, or for any language that provides C bindings. · APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and Tcl are available, allowing MySQL clients to be written in many languages. · The Connector/ODBC (MyODBC) interface provides MySQL support for client programs that use ODBC (Open Database Connectivity) connections. For example, you can use MS Access to connect to your MySQL server. Clients can be run on Windows or Unix. MyODBC source is available. All ODBC 2.5 functions are supported, as are many others. · The Connector/J interface provides MySQL support for Java client programs that use JDBC connections. Clients can be run on Windows or Unix. Connector/J source is available. · MySQL Connector/NET enables developers to easily create .NET applications that require secure, high-performance data connectivity with MySQL. It implements the required ADO.NET interfaces and
  • 4. 4 integrates into ADO.NET aware tools. Developers can build applications using their choice of .NET languages. MySQL Connector/NET is a fully managed ADO.NET driver written in 100% pure C#. Localization: · The server can provide error messages to clients in many languages. · Full support for several different character sets, including latin1 (cp1252), german, big5, ujis, and more. For example, the Scandinavian characters “å”, “ä” and “ö” are allowed in table and column names. Unicode support is available as of MySQL 4.1. · All data is saved in the chosen character set. · Sorting and comparisons are done according to the chosen character set and collation (using latin1 and Swedish collation by default). It is possible to change this when the MySQL server is started. To see an example of very advanced sorting, look at the Czech sorting code. MySQL Server supports many different character sets that can be specified at compile time and runtime. · As of MySQL 4.1, the server time zone can be changed dynamically, and individual clients can specify their own time zone.
  • 5. 5 2. Write the differences between char and varchar data types in MySQL. The CHAR and VARCHAR types are similar, but differ in the way they are stored and retrieved. They also differ in maximum length and in whether trailing spaces are retained. The CHAR and VARCHAR types are declared with a length that indicates the maximum number of characters you want to store. For example, CHAR(30) can hold up to 30 characters. The length of a CHAR column is fixed to the length that you declare when you create the table. The length can be any value from 0 to 255. When CHAR values are stored, they are right-padded with spaces to the specified length. When CHAR values are retrieved, trailing spaces are removed unless the PAD_CHAR_TO_FULL_LENGTH SQL mode is enabled.
  • 6. 6 Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 65,535. The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used. In contrast to CHAR, VARCHAR values are stored as a one-byte or two-byte length prefix plus data. The length prefix indicates the number of bytes in the value. A column uses one length byte if values require no more than 255 bytes, two length bytes if values may require more than 255 bytes. If strict SQL mode is not enabled and you assign a value to a CHAR or VARCHAR column that exceeds the column’s maximum length, the value is truncated to fit and a warning is generated. For truncation of non-space characters, you can cause an error to occur (rather than a warning) and suppress insertion of the value by using strict SQL mode. For VARCHAR columns, trailing spaces in excess of the column length are truncated prior to insertion and a warning is generated, regardless of the SQL mode in use. For CHAR columns, truncation of excess trailing spaces from inserted values is performed silently regardless of the SQL mode. VARCHAR values are not padded when they are stored. Trailing spaces are retained when values are stored and retrieved, in conformance with standard SQL.
  • 7. 7 3. Write about the operations supported by indexes in MySQL. Indexes are used to find rows with specific column values quickly. Without an index, MySQL must begin with the first row and then read through the entire table to find the relevant rows. The larger the table, the more is the cost. If the table has an index for the columns in question, MySQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data. If a table has 1,000 rows, this is at least 100 times faster than reading sequentially. If you need to access most of the rows, it is faster to read sequentially, because this minimizes disk seeks. If a multiple-column index exists on col1 and col2, the appropriate rows can be fetched directly. If separate single-column indexes exist on col1 and col2, the optimizer will attempt to use the Index Merge optimization, or attempt to find the most restrictive index by deciding which index finds fewer rows and using that index to fetch the rows. Index Merge optimization: The Index Merge method is used to retrieve rows with several range scans and to merge their results into one. The merge can produce unions, intersections, or unions-of- intersections of its underlying scans. This access method merges index scans from a single table; it does not merge scans across multiple tables.MySQL uses indexes for these operations: · To find the rows matching a WHERE clause quickly.
  • 8. 8 · To eliminate rows from consideration. If there is a choice between multiple indexes, MySQL normally uses the index that finds the smallest number of rows. · To retrieve rows from other tables when performing joins. MySQL can use indexes on columns more efficiently if they are declared as the same type and size. In this context, VARCHAR and CHAR are considered the same if they are declared as the same size. For example, VARCHAR(10) and CHAR(10) are the same size, but VARCHAR(10) and CHAR(15) are not. Comparison of dissimilar columns may prevent use of indexes if values cannot be compared directly without conversion. Suppose that a numeric column is compared to a string column. For a given value such as 1 in the numeric column, it might compare equal to any number of values in the string column such as '1', ' 1', '00001', or '01.e1'. This rules out use of any indexes for the string column. · To find the MIN() or MAX() value for a specific indexed column key_col. This is optimized by a preprocessor that checks whether you are using WHERE key_part_N = constant on all key parts that occur before key_col in the index. In this case, MySQL does a single key lookup for each MIN() or MAX() expression and replaces it with a constant. If all expressions are replaced with constants, the query returns at once.
  • 9. 9 4. Write the SQL statements to demonstrate the following using SELECT command: a. Expression Evaluation
  • 10. 10 b. Using table aliases c. ORDER BY 5. Define the following types of Joins: a. Inner Join they are also known as Equi Joins. They are so called because the where statement generally compares two columns from two tables with the equivalence operator =. Many systems use this type as the default join. This type can be used in situations where selecting only
  • 11. 11 those rows that have values in common in the columns specified in the ON clause, is required. In short, the Inner Join returns all rows from both tables where there is a match. mysql> SELECT ProdName, Quantity FROM Products, Sales WHERE Products.ProdID = Sales.ProdID AND Sales.Quantity > 2000; b. Left Outer Join In this type, all the records from the table on the left side of the join and matching the WHERE clause in appear in the final result set. mysql> SELECT * FROM users LEFT JOIN users_groups ON users.uid = users_groups.uid; c. Right Outer Join All the records matching the WHERE clause from the table on the right appear. mysql> SELECT * FROM users_groups RIGHT JOIN groups USING (gid);
  • 12. 12 6. Give the advantages of subqueries. A Subquery is exactly what it sounds like: a SELECT query that is subordinate to another query. This unit covers the various concepts of subqueries. 1. The subquery as scalar operand: A scalar subquery is a simple operand, and you can use it almost anywhere a single column value or literal is legal, and you can expect it to have those characteristics that all operands have: a data type, a length, an indication whether it can be NULL, and so on. 2. Comparisons Using Subqueries: The output of the subqueries can be used to compare the output of the outer most queries. This can be done using various comparison operators like >, <, IN, and so on. 3. Subqueries with ANY, IN, and SOME: These type of subqueries can be used in cases where a set of values need to be compared and the output determined.
  • 13. 13 4. Subqueries with ALL: These type of subqueries can be used in cases where a set of values are the output generated by the inner or subqueries and the output is possible only if all the values match with the outer query. 5. Correlated Subqueries: Sometimes a situation arises in which a subquery uses a field from the main query in its clause. Such a reference by a subquery to a field in its enclosing query, is called an outer reference, and the corresponding subquery is called a correlated subquery, because it’s correlated with the result set of one or more of the queries enclosing it. 6. EXISTS and NOT EXISTS: The Exists operator can be used to check if a subquery produces any results at all. The NOT EXISTS operator is exactly the opposite of the output produced by NOT EXISTS. 7. Row Subqueries: A row subquery is a subquery variant that returns a single row and can thus return more than one column value. 7. Subqueries in the FROM Clause: Subqueries are legal in a
  • 14. 14 SELECT statement’s FROM clause. Any columns in the subquery select list must have unique names. 7. Discuss any five string functions. String-valued functions return NULL if the length of the result would be greater than the value of the max_allowed_packet system variable. For functions that operate on string positions, the first position is numbered 1. 1,ASCII(str)-Returns the numeric value of the leftmost character of the string str. Returns 0 if str is the empty string. Returns NULL if str is NULL. ASCII() works for characters with numeric values from 0 to 255.1. SELECT ASCII(’2 );′ 2,BIN(N)-Returns a string representation of the binary value of N, where N is a longlong (BIGINT) number. SELECT BIN(12); 3,BIT_LENGTH(str)-Returns the length of the string str in bits.SELECT BIT_LENGTH(’text’); 4,CHAR(N,…)--CHAR() interprets the arguments as integers and returns a string consisting of the characters given by the code values
  • 15. 15 of those integers. NULL values are skipped.1.SELECT CHAR(77,121,83,81,’76 );SELECT INSERT(’Quadratic’, 3, 4, ‘What’);′ 5,INSERT(str,pos,len,newstr)--Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr. 8. Describe the operators that support the boolean full-text searches. MySQL can perform boolean full-text searches using the IN BOOLEAN MODE modifier:· +: A leading plus sign indicates that this word must be present in each row that is returned. · -: A leading minus sign indicates that this word must not be present in any of the rows that are returned. Note: The – operator acts only to exclude rows that are otherwise matched by other search terms. Thus, a boolean-mode search that contains only terms preceded by – returns an empty result. It does not return “all rows except those containing any of the excluded
  • 16. 16 terms.” · (no operator): By default (when neither + nor – is specified) the word is optional, but the rows that contain it are rated higher. This mimics the behavior of MATCH() … AGAINST() without the IN BOOLEAN MODE modifier. · > <: These two operators are used to change a word’s contribution to the relevance value that is assigned to a row. The > operator increases the contribution and the < operator decreases it. · ( ): Parentheses group words into subexpressions. Parenthesized groups can be nested. · ~: A leading tilde acts as a negation operator, causing the word's contribution to the row's relevance to be negative. This is useful for marking “noise” words. A row containing such a word is rated lower than others, but is not excluded altogether, as it would be with the - operator. · *: The asterisk serves as the truncation (or wildcard) operator. Unlike the other operators, it should be appended to the word to be affected. Words match if they begin with the word preceding the *
  • 17. 17 operator. If a stopword or too-short word is specified with the truncation operator, it will not be stripped from a boolean query. For example, a search for '+word +stopword*' will likely return fewer rows than a search for '+word +stopword' because the former query remains as is and requires stopword* to be present in a document. The latter query is transformed to +word. · ": A phrase that is enclosed within double quote (“"”) characters matches only rows that contain the phrase literally, as it was typed. The full-text engine splits the phrase into words, performs a search in the FULLTEXT index for the words. Non-word characters need not be matched exactly: Phrase searching requires only that matches contain exactly the same words as the phrase and in the same order. 9. Describe the Savepoint and Rollback to Savepoint Syntaxes.
  • 18. 18 Starting from MySQL 4.0.14 and 4.1.1, InnoDB supports the SQL statements SAVEPOINT and ROLLBACK TO SAVEPOINT. The SAVEPOINT statement sets a named transaction savepoint with a name of identifier. If the current transaction already has a savepoint with the same name, the old savepoint is deleted and a new one is set. The ROLLBACK TO SAVEPOINT statement rolls back a transaction to the named savepoint. Modifications that the current transaction made to rows after the savepoint was set are undone in the rollback, but InnoDB does not release the row locks that were stored in memory after the savepoint. (Note that for a new inserted row, the lock information is carried by the transaction ID stored in the row; the lock is not separately stored in memory. In this case, the row lock is released in the undo.) Savepoints that were set at a later time than the named savepoint are deleted. 10.Give the syntax of BEGIN…END compound statement.
  • 19. 19 Stored routines may contain multiple statements, using a BEGIN … END compound statement. begin_label and end_label must be the same, if both are specified. Please note that the optional [NOT] ATOMIC clause is not yet supported. This means that no transactional savepoint is set at the start of the instruction block and the BEGIN clause used in this context has no effect on the current transaction. Multiple statements requires that a client is able to send query strings containing ‘;’. This is handled in the mysql command-line client with the delimiter command. Changing the ‘;’ end-of-query delimiter (for example, to ‘|’) allows ‘;’ to be used in a routine body.