Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PL/MySQL does it exist?

In Oracle there is PL/SQL, a powerful imperative language. Is there anything similar for MySQL?

like image 564
user1081596 Avatar asked Mar 21 '12 16:03

user1081596


People also ask

Is PL SQL outdated?

The answer is that PL/SQL is not growing, but not going away either. Because it is used in the Oracle database, and the Oracle database is a fixture of enterprise systems world-wide, it will outlive you. High-performance batch processing has to happen close to the data, so PL/SQL will continue to rule in this area.

Is Plsql same as MySQL?

PL/SQL can be a bit more complex and potentially more powerful, while T-SQL is much more simple and easier to implement. MySQL, on the other hand, uses the light version of T-SQL and also combines procedural language that closely relates to SQL/PSM.

Is SQL and PL SQL are same?

No, Oracle SQL is not the same as PL/SQL. Oracle SQL is Oracle's version of the structured query language. On the other hand, PL/SQL is a Procedural Language developed by Oracle is an extension of Oracle SQL having the functionalities of functions, control structures, and triggers.


2 Answers

While MySQL does have similar components, no, you cannot use PL\SQL in MySQL. The same goes for T-SQL used by MS SQL Server.

MySQL has plenty of documentation on it at their website.

You'll see that both PL\SQL and T-SQL are Turing-complete, and probably provide slightly more functionality. But MySQL has plenty of ways to perform similar tasks.

Here is the content from the Yahoo Answers post:

MySQL is a multithreaded, multi-user SQL database management system (DBMS)1 which has, according to MySQL AB, more than 10 million installations.

Libraries for accessing MySQL databases are available in all major programming languages with language-specific APIs. In addition, an ODBC interface called MyODBC allows additional programming languages that support the ODBC interface to communicate with a MySQL database, such as ASP or Coldfusion. The MySQL server and official libraries are mostly implemented in ANSI C.

MySQL is popular for web applications and acts as the database component of the LAMP, MAMP, and WAMP platforms (Linux/Mac/Windows-Apache-MySQL-PHP/Perl... and for open-source bug tracking tools like Bugzilla. Its popularity as a web application is closely tied to the popularity of PHP, which is often combined with MySQL. PHP and MySQL are essential components for running the popular WordPress blogging platform.

The following features are implemented by MySQL but not by some other RDBMSes:

  • Multiple storage engines, allowing you to choose the one which is most effective for each table in the application (in MySQL 5.0, storage engines must be compiled in; in MySQL 5.1, storage engines can be dynamically loaded at run time): o Native storage engines (MyISAM, Falcon, Merge, Memory (heap), Federated, Archive, CSV, Blackhole, Cluster) -Partner-developed storage engines (InnoDB, solidDB, NitroEDB, BrightHouse) -Community-developed storage engines
  • Custom storage engines
  • Commit grouping, gathering multiple transactions from multiple connections together to increase the number of commits per second.

Note:: MySQL is written in C and C++. The SQL parser uses yacc and home-brewed lexer. A document describing some of the internal structures of the code and the coding guidelines is available from the MySQL web site.

SQL


SQL commonly expanded as Structured Query Language, is a computer language designed for the retrieval and management of data in relational database management systems, database schema creation and modification, and database object access control management.

The SQL language is sub-divided into several language elements, including:

  • Statements which may have a persistent effect on schemas and data, or which may control transactions, program flow, connections, sessions, or diagnostics.
  • Queries which retrieve data based on specific criteria.
  • Expressions which can produce either scalar values or tables consisting of columns and rows of data.
  • Predicates which specify conditions that can be evaluated to SQL three-valued logic (3VL) Boolean truth values and are commonly used to limit the effects of statements and queries, or to change program flow.
  • Clauses which are (in some cases optional) constituent components of statements and queries

it works under..concept of query data manipulation data defination transaction control

The SQL:2003 standard makes minor modifications to all parts of SQL:1999, and officially introduces a few new features such as:1

  • XML-related features
  • window functions
  • the sequence generator, which allows standardized sequences
  • two new column types: auto-generated values and identity-columns
  • the new MERGE statement
  • extensions to the CREATE TABLE statement, to allow "CREATE TABLE AS" and "CREATE TABLE LIKE"
  • removal of the poorly-implemented "BIT" and "BIT VARYING" data types

PL/SQL


PL/SQL is Oracle Corporation's proprietary server-based procedural extension to the SQL database language. (Some other SQL database management systems offer languages similar to PL/SQL.) Its syntax strongly resembles that of Ada.

PL/SQL supports variables, conditions, arrays, and exceptions. Implementations from version 8 of the Oracle RDBMS onwards have included features associated with object-orientation.

The underlying SQL functions as a declarative language. Standard SQL—unlike some functional programming languages—does not require implementations to convert tail calls to jumps. SQL does not readily provide "first row" and "rest of table" accessors, and it cannot easily perform some constructs such as loops. PL/SQL, however, as a Turing-complete procedural language which fills in these gaps, allows Oracle database developers to interface with the underlying relational database in an imperative manner. SQL statements can make explicit in-line calls to PL/SQL functions, or can cause PL/SQL triggers to fire upon pre-defined Data Manipulation Language (DML) events.

PL/SQL stored procedures (functions, procedures, packages, and triggers) which perform DML get compiled into an Oracle database: to this extent their SQL code can undergo syntax-checking. Programmers working in an Oracle database environment can construct PL/SQL blocks of such functionality to serve as procedures, functions; or they can write in-line segments of PL/SQL within SQL*Plus scripts.

While programmers can readily incorporate SQL DML statements into PL/SQL (as cursor definitions, for example, or using the SELECT ... INTO syntax), Data Definition Language (DDL) statements such as CREATE TABLE/DROP INDEX etc require the use of "Dynamic SQL". Earlier versions of Oracle required the use of a complex built-in DBMS_SQL package for Dynamic SQL where the system needed to explicitly parse and execute an SQL statement. Later versions have included an EXECUTE IMMEDIATE syntax called "Native Dynamic SQL" which considerably simplifies matters. Any use of DDL in Oracle will result in an implicit commit. Programmers can also use Dynamic SQL to execute DML where they do not know the exact content of the statement in advance.

PL/SQL offers several pre-defined packages for specific purposes. Such PL/SQL packages include:

  • DBMS_OUTPUT - for output operations to non-database destinations
  • DBMS_JOB - for running specific procedures/functions at a particular time (i.e. scheduling)
  • DBMS_XPLAN - for formatting "Explain Plan" output
  • DBMS_SESSION - provides access to SQL ALTER SESSION and SET ROLE statements, and other session information.
  • DBMS_METADATA - for extracting meta data from the data dictionary (such as DDL statements)
  • UTL_FILE - for reading and writing files on disk
  • UTL_HTTP - for making requests to web servers from the database
  • UTL_SMTP - for sending mail from the database (via an SMTP server)

Oracle Corporation customarily adds more packages and/or extends package functionality with each successive release of the Oracle DBMS.

like image 113
Michael Capobianco Avatar answered Sep 21 '22 08:09

Michael Capobianco


Terminology Problem

Some relational database vendors follow the traditional definition of SQL, which defines it as a declarative language. Examples of these vendors include PostgreSQL, IBM, Oracle. For these databases vendors you write procedural code in their own procedural languages they provide which may or may not make available SQL.

Some vendors though see their procedural language as an extension to SQL. These vendors don't have any such differentiation. For example, in MySQL a "Stored Program" is declared with LANGUAGE SQL even though it provides different language-features (like LEAVE, REPEAT and UNTIL that are not provided elsewhere). So you have essentially a different "SQL Language" in a "SQL Routine" then you have in a query expression. Other vendors like Microsoft call everything they do with just one term -- "T-SQL". This dropping of a term makes it hard to find equivalent features in other databases, or to know what features are likely to be different.

The procedural features being entirely standardized are likely to be different. While the declarative query syntax is likely to be similar because there is a spec on it.

like image 41
NO WAR WITH RUSSIA Avatar answered Sep 20 '22 08:09

NO WAR WITH RUSSIA