Sie sind auf Seite 1von 8

c 

 (pronounced Ô ÔÔ or ÔÔ): often referred to as 





 À   is a database
computer language designed for managing data in relational database management systems (RDBMS)À and
originally based upon relational algebra. Its scope includes data query and updateÀ schema creation and
modificationÀ and data access control. SQL was one of the first languages for Edgar F. Codd's relational model in his
influential 1970 paperÀ "A Relational Model of Data for Large Shared Data Banks"  and became the most widely
used language for relational databases.  





 
As indicated aboveÀ a very popular data base language for data definitionÀ manipulationÀ
and query is structured query language (SQL). In the context of the three types of
database languages discussed earlier (i.e.À DDLÀ DMLÀ and DQL)À SQL includes
statements for all three purposes. The set of "create" commands within SQL are used to
define tablesÀ i.e.À as a DDL. SQL statements can be embedded into conventional
programming languages (i.e.À used as a DML). FinallyÀ and in its most common useÀ SQL
can be used as a DQL by end users seeking answers to ad hoc queries. There are four
primary operations that can be performed on tables using SQL -- the SELECT operation
(to select rows from one or more tables)À the INSERT operation (to insert rows into a
table)À the UPDATE operation (to modify one or more rows in a table)À and the DELETE
operation (to delete one or more rows from a table). The most commonly used SQL
operation to answer ad hoc queries is the SELECT operation. The SELECT operation
can simultaneously (1) create a horizontal subset of a tableÀ i.e.À selecting all rows from a
table that meet a certain conditionÀ () link tables using the common field between themÀ
and () create a vertical subset of a table or tablesÀ i.e.À displaying only certain fields in

tables.

  

The    (pronounced à ) of a database system is its structure described in a formal language supported by
the database management system (DBMS). In a relational databaseÀ the schema defines the tablesÀ the fieldsÀ
relationshipsÀ viewsÀ indexesÀ packagesÀ proceduresÀ functionsÀ queuesÀ triggersÀ typesÀ sequencesÀ materialized
viewsÀ synonymsÀ database linksÀ directoriesÀ JavaÀ XML schemasÀ and other elements.

Schemas are generally stored in a data dictionary. Although a schema is defined in text database languageÀ the term
is often used to refer to a graphical depiction of the database structure. In other wordsÀ schema is the structure of the
database that defines the objects in the database.

In an Oracle systemÀ the term "schema" has a slightly difference connotation. For the interpretation used in OracleÀ
see schema object.

  

The SQLPlus command   returns the definitions of tables and views. For exampleÀ information about your
tables are stored in the table Ê . HoweverÀ since you do know the columns names of that tableÀ you can not query
that table. The command

describe tabs;
will produces that information
Name Null? Type
------------------------------- -------- ----
TABLE_NAME NOT NULL VARCHAR2(30)
TABLESPACE_NAME VARCHAR2(30)
CLUSTER_NAME VARCHAR2(30)
IOT_NAME VARCHAR2(30)
PCT_FREE NUMBER
PCT_USED NUMBER
INI_TRANS NUMBER
MAX_TRANS NUMBER
INITIAL_EXTENT NUMBER
NEXT_EXTENT NUMBER
MIN_EXTENTS NUMBER
MAX_EXTENTS NUMBER
PCT_INCREASE NUMBER
FREELISTS NUMBER
FREELIST_GROUPS NUMBER
LOGGING VARCHAR2(3)
BACKED_UP VARCHAR2(1)
NUM_ROWS NUMBER
BLOCKS NUMBER
EMPTY_BLOCKS NUMBER
AVG_SPACE NUMBER
CHAIN_CNT NUMBER
AVG_ROW_LEN NUMBER
AVG_SPACE_FREELIST_BLOCKS NUMBER
NUM_FREELIST_BLOCKS NUMBER
DEGREE VARCHAR2(10)
INSTANCES VARCHAR2(10)
CACHE VARCHAR2(5)
TABLE_LOCK VARCHAR2(8)
SAMPLE_SIZE NUMBER
LAST_ANALYZED DATE
PARTITIONED VARCHAR2(3)
IOT_TYPE VARCHAR2(12)
TEMPORARY VARCHAR2(1)
NESTED VARCHAR2(3)
BUFFER_POOL VARCHAR2(7)
The first column is the list of column names. The second column is a list of Not Null indicators. The third column is
the list of data types. This output reveals that the column name "TABLE_NAME" is not allowed to be null. Now to
get an alphabetical list of all the tables in your accountÀ use the command
select table_name from tabs order by table_name;
You can use the describe command on the following views to obtain information on your account.
o     
 table names and table description
c column names of table names and column description
! names of all user's tablesÀ viewsÀ synonymsÀ and sequences
"# information on all objects in your account
!" table information on all user's tables
 column information on all user's columns
c$%o$& view information on all user's views
' synonyms information on all user's synonyms
$ sequence information on all user's sequences
c$% %!  constraint information on user's constraints
c$% c  column information on user's constraints
  index information on all user's indices
c$% c  column information on user's indices

 

 ( )

Is a family of computer languages used by computer programs and/or database users to insertÀ delete and update data
in a database. Read-only queryingÀ i.e. SELECTÀ of this data may be considered to be either part of DML or outside
itÀ depending on the context.

Currently the most popular data manipulation language is that of SQLÀ which is used to retrieve and manipulate data
in a Relational database. 1 Other forms of DML are those used by IMS/DLIÀ CODASYL databases (such as IDMS)À
and others.

Data Manipulation Language comprises the 'SQL-data change' statements À which modify stored data but not the
schema or database objects. Manipulation of persistent database à Ô (e.g. tables or stored procedures) via the
'SQL-schema' statements À rather than the
  stored within themÀ is considered to be part of a separate Data
Definition Language. In SQL these two categories are similar in their detailed syntaxÀ data typesÀ expressions etc.À
but distinct in their overall function. 

Data Manipulation Languages have their functional capability organized by the initial word in a statementÀ which is
almost always a verb. In the case of SQLÀ these verbs are:

’ SELECT ... INTO


’ INSERT
’ UPDATE
’ DELETE

The purely read-only SELECT query statement is classed with the 'SQL-data' statements  and so is considered by
the standard to be outside of DML. The SELECT ... INTO form is considered to be DML because it manipulates
(i.e. modifies) data. In common practice thoughÀ this distinction is not made and SELECT is widely considered to be
part of DML. 

Most SQL database implementations extend their SQL capabilities by providing imperativeÀ i.e.À proceduralÀ
languages. Examples of these are Oracle's PL/SQL and DB's SQL PL.

Data manipulation languages tend to have many different flavors and capabilities between database vendors. There
have been a number of standards established for SQL by ANSIÀ 1 but vendors still provide their own extensions to
the standard while not implementing the entire standard.

There are two types of data manipulation languages:

’ Procedural
’ Declarative
Each SQL DML statement is a declarative command. The individual SQL statements are declarativeÀ as opposed to
imperativeÀ in that they describe   the program should accomplishÀ rather than describing à to go about
accomplishing it.

      

       
    
             

A   ( is a computer program that provides database services to other computer programs or computersÀ
as defined by the client±server model. The term may also refer to a computer dedicated to running such a program.
Database management systems frequently provide database server functionalityÀ and some DBMSs (e.g.À MySQL)
rely exclusively on the client±server model for database access.

Such a server is accessed either through a "front end" running on the user¶s computer which displays requested data
or the back end which runs on the server and handles tasks such as data analysis and storage.

In a master-slave modelÀ database master servers are central and primary locations of data while database slave
servers are synchronized backups of the master acting as proxies.

Some examples of Database servers are OracleÀ DBÀ InformixÀ IngresÀ SQL Server. Every server uses its own query
logic and structure. The SQL query language is more or less the same in all the database servers.



)  

 (G)

†      



 
    
       
 

       
          
  

          


  
  
  
  
                   †   

     
 
              
!         †             

  
   

  (   

A   ( is a computer program that provides database services to other computer programs or computersÀ
as defined by the client±server model. The term may also refer to a computer dedicated to running such a program.
Database management systems frequently provide database server functionalityÀ and some DBMSs (e.g.À MySQL)
rely exclusively on the client±server model for database access.

Such a server is accessed either through a "front end" running on the user¶s computer which displays requested data
or the back end which runs on the server and handles tasks such as data analysis and storage.

In a master-slave modelÀ database master servers are central and primary locations of data while database slave
servers are synchronized backups of the master acting as proxies.

Some examples of Database servers are OracleÀ DBÀ InformixÀ IngresÀ SQL Server. Every server uses its own query
logic and structure. The SQL query language is more or less the same in all the database servers.

In relational databases and flat file databasesÀ a  is a set of data elements (values) that is
organized using a model of vertical columns (which are identified by their name) and horizontal
rows. A table has a specified number of columnsÀ but can have any number of rows. Each row is
identified by the values appearing in a particular column subset which has been identified as a
candidate key.

Table is another term for relations; although there is the difference in that a table is usually a
multi-set (bag) of rows whereas a relation is a set and does not allow duplicates. Besides the
actual data rowsÀ tables generally have associated with them some meta-informationÀ such as
constraints on the table or on the values within particular columns.

The data in a table does not have to be physically stored in the database. Views are also
relational tablesÀ but their data are calculated at query time. Another example are nicknamesÀ
which represent a pointer to a table in another database.




The Data Manipulation Language (DML) is the subset of SQL used to addÀ update and delete
data:

’ INSERT adds rows (formally tuples) to an existing tableÀ e.g.À:

INSERT INTO My_table


(field1, field2, field3)
VALUES
('test', 'N', NULL);

’ UPDATE modifies a set of existing table rowsÀ e.g.À:

UPDATE My_table
SET field1 = 'updated value'
WHERE field2 = 'N';

’ DELETE removes existing rows from a tableÀ e.g.À:

DELETE FROM My_table


WHERE field2 = 'N';

’ TRUNCATE deletes all data from a table in a very fast way. It usually implies a subsequent
COMMIT operation.
’ MERGE is used to combine the data of multiple tables. It combines the INSERT and UPDATE
elements. It is defined in the SQL:00 standard; prior to thatÀ some databases provided
similar functionality via different syntaxÀ sometimes called "upsert".

    
 


  "                  #    
  $       % %&'   &%         
               #      $     




& 
 
   #      $              
   (        )           
    #      $        *        
       *
*           

&  
 +   
   !                   
 
†        
        
  
     

                            


           ( (    

G  
   
x  
                
            
             


        !

   
"    #       #     
$    $   %   #   
#

       
&
    ! 
#

 
  
      
             
 
à  ! 
#


  
           
  
  
    
'   
 (   

) (   

 
  
 

        "     !

CREATE TABLE #table_name# (

#column_name# #data_type# [#default_value#] [NULL|NOT NULL] #column_restrictions#

#column_name# #data_type# [#default_value#] [NULL|NOT NULL] #column_restrictions#,

#table_restrictions# )

(    !

*x+(x, -.,!      


  /    

c&c. 0-.,1!           
   2

0)3x.4& -.,1 x.).x.&". 5  55


5!       /   
 
  

"6."- 0"3&x(&1 57 # 5!   #    

.#
         !

create table student

ID int primary keyÀ

Name Varchar(0) not nullÀ

IdentityNumber int not null uniqueÀ

Faculty Varchar(0) default ¶Informatics¶

create table course

ID int primary keyÀ

Name Varchar(0)

)
create table result

StudentID int references student(ID)À

CourseID int references course(ID)À

ExamDate datetimeÀ

Result intÀ

Primary key (StudentIDÀ CourseIDÀ ExamDate)

Das könnte Ihnen auch gefallen