c3d2-wiki/SQL.mw

244 lines
5.6 KiB
Plaintext
Raw Normal View History

2008-01-09 16:12:39 +01:00
[[Kategorie:Wissen]][[Kategorie:SQL]]
2006-08-10 12:20:59 +02:00
2006-12-07 18:26:07 +01:00
=Funktionen und Operatoren=
==ASCII-Code -> String==
{| border="1" cellspacing="0" cellpadding="3" style="border-collapse: collapse;"
|---- bgcolor="lightblue"
!
!Befehl
!Ergebnis
|-
| Standard
| chr(65)
| 'A'
|-
| MySQL
| char(65)
| 'A'
|}
2006-12-24 04:35:43 +01:00
==String -> ASCII-Code==
{| border="1" cellspacing="0" cellpadding="3" style="border-collapse: collapse;"
|---- bgcolor="lightblue"
!
!Befehl
!Ergebnis
|-
| Standard
| ascii('A')
| 65
|}
2006-12-07 18:26:07 +01:00
==Text verketten==
{| border="1" cellspacing="0" cellpadding="3" style="border-collapse: collapse;"
|---- bgcolor="lightblue"
!
!Befehl
!Ergebnis
|-
| Standard
| 'chunky' || 'bacon'
| 'chunkybacon'
|-
| MySQL
| concat('chunky','bacon')
| 'chunkybacon'
|}
==Text ersetzen==
{| border="1" cellspacing="0" cellpadding="3" style="border-collapse: collapse;"
|---- bgcolor="lightblue"
!
!Befehl
!Ergebnis
|-
| Standard
| replace('funky bacon','funky','chunky')
| 'chunky bacon'
|}
2006-12-07 17:58:17 +01:00
=Meta-Daten abfragen=
2006-12-07 19:29:39 +01:00
==Datenbanken==
2006-12-07 18:50:08 +01:00
{| border="1" cellspacing="0" cellpadding="3" style="border-collapse: collapse;"
|---- bgcolor="lightblue"
!Beschreibung
!Befehl
|-
| MySQL
2006-12-07 19:29:39 +01:00
| SHOW DATABASES;
2006-12-07 18:50:08 +01:00
|-
2006-12-07 19:06:23 +01:00
| PostgreSQL
2006-12-07 19:29:39 +01:00
| SELECT * FROM pg_database;
|-
| SQLite
| PRAGMA database_list;
2006-12-07 18:50:08 +01:00
|}
2006-12-07 19:29:39 +01:00
==Tabellen==
2006-12-07 19:06:23 +01:00
{| border="1" cellspacing="0" cellpadding="3" style="border-collapse: collapse;"
|---- bgcolor="lightblue"
!Beschreibung
!Befehl
|-
2006-12-07 19:29:39 +01:00
| Standard ||
* SELECT * FROM information_schema.tables;
2006-12-07 19:06:23 +01:00
|-
| Firebird ||
2006-12-07 19:47:02 +01:00
* SELECT RDB$RELATION_NAME FROM RDB$RELATIONS;
2006-12-07 19:06:23 +01:00
|-
2006-12-08 18:01:38 +01:00
| MySQL (unterstützt Standard ab 5.0) ||
2006-12-07 19:29:39 +01:00
* SHOW TABLES;
|-
| SQLite ||
2006-12-07 19:47:02 +01:00
* SELECT * FROM SQLite_Master;
|-
2006-12-08 18:01:38 +01:00
| PostgreSQL (unterstützt Standard seit 7.4) ||
2006-12-07 20:02:40 +01:00
* SELECT * FROM pg_tables;
2010-05-03 09:08:18 +02:00
|-
| Oracle ||
* SELECT * FROM ALL_TABLES;
2006-12-07 19:06:23 +01:00
|}
2006-12-07 19:29:39 +01:00
==Spalten einer Tabelle==
2006-08-10 12:20:59 +02:00
2006-08-17 10:40:31 +02:00
{| border="1" cellspacing="0" cellpadding="3" style="border-collapse: collapse;"
|---- bgcolor="lightblue"
!Beschreibung
!Befehl
|-
2006-12-07 19:29:39 +01:00
| Standard ||
* SELECT * FROM information_schema.columns WHERE table_name = '<table_name>';
2006-08-17 10:40:31 +02:00
|-
2006-12-07 19:29:39 +01:00
| Firebird ||
*SELECT RDB$FIELD_NAME FROM RDB$RELATION_FIELDS WHERE RDB$RELATION_NAME='<table_name>';
2006-08-17 10:40:31 +02:00
|-
2006-12-07 19:29:39 +01:00
| MySQL ||
*SHOW COLUMNS FROM <table>;
*DESCRIBE <table>;
|-
| SQLite ||
*PRAGMA table_info(<table>);
2010-05-03 15:17:17 +02:00
|-
| Oracle ||
*DESCRIBE <table>;
2006-08-17 10:40:31 +02:00
|}
2006-08-10 12:20:59 +02:00
2006-12-07 19:29:39 +01:00
==User==
2006-08-10 11:51:38 +02:00
2006-08-17 10:32:11 +02:00
{| border="1" cellspacing="0" cellpadding="3" style="border-collapse: collapse;"
|---- bgcolor="lightblue"
!Beschreibung
!Befehl
|-
2006-12-07 19:29:39 +01:00
| Standard
| SELECT * FROM information_schema.enabled_roles;
2006-08-17 10:32:11 +02:00
|-
2006-12-07 19:29:39 +01:00
| Firebird
| SELECT DISTINCT RDB$USER FROM RDB$USER_PRIVILEGES;
2006-08-17 10:32:11 +02:00
|-
2006-12-07 19:29:39 +01:00
| MySQL
| SELECT * FROM mysql.user;
2006-08-17 10:32:11 +02:00
|-
2006-12-07 19:29:39 +01:00
| PostgreSQL
(unterstützt außerdem Standard)
| SELECT * FROM pg_user;
2010-05-03 12:22:54 +02:00
|-
| Oracle
| SELECT * FROM ALL_USERS;
2006-08-17 10:32:11 +02:00
|}
2006-08-06 14:51:04 +02:00
2006-12-07 19:29:39 +01:00
==User-Rechte==
2006-08-06 14:51:04 +02:00
{| border="1" cellspacing="0" cellpadding="3" style="border-collapse: collapse;"
|---- bgcolor="lightblue"
!Beschreibung
!Befehl
|-
2006-12-07 19:29:39 +01:00
| Standard ||
* SELECT * FROM information_schema.role_table_grants;
* SELECT * FROM information_schema.role_column_grants;
* SELECT * FROM information_schema.role_routine_grants;
* SELECT * FROM information_schema.role_usage_grants;
2006-08-18 12:57:34 +02:00
|-
2006-12-07 19:29:39 +01:00
| Firebird ||
* SELECT * FROM RDB$USER_PRIVILEGES;
|-
2006-12-07 19:29:39 +01:00
| MySQL ||
* SHOW GRANTS;
|}
2006-08-06 16:45:41 +02:00
2006-12-07 19:29:39 +01:00
==Prozeduren==
2006-08-09 14:47:48 +02:00
2006-08-17 10:50:36 +02:00
{| border="1" cellspacing="0" cellpadding="3" style="border-collapse: collapse;"
|---- bgcolor="lightblue"
!Beschreibung
!Befehl
|-
2006-12-07 19:29:39 +01:00
| Standard
| SELECT * FROM information_schema.routines;
2006-08-17 10:50:36 +02:00
|-
2006-12-07 19:29:39 +01:00
| Firebird
| SELECT * FROM RDB$PROCEDURES;
2010-05-03 16:27:36 +02:00
|-
| Oracle
| select * from user_objects where object_type = 'PROCEDURES';
2006-08-17 10:50:36 +02:00
|}
2006-12-07 18:00:36 +01:00
2006-12-07 20:04:26 +01:00
==Version==
{| border="1" cellspacing="0" cellpadding="3" style="border-collapse: collapse;"
|---- bgcolor="lightblue"
!Beschreibung
!Befehl
|-
2007-01-16 00:11:59 +01:00
| MS SQL
| SELECT @@VERSION;
|-
| MySQL
2008-01-06 15:20:51 +01:00
| SELECT version();
SHOW VARIABLES LIKE 'version%';
|-
2006-12-07 20:04:26 +01:00
| PostgreSQL
| SELECT version();
2010-05-03 13:23:02 +02:00
|-
| Oracle
| SELECT * FROM V$VERSION;
2006-12-07 20:04:26 +01:00
|}
2006-12-07 18:00:36 +01:00
=Dokumentation=
*[http://www.firebirdsql.org/ Firebird]
**[http://www.ibphoenix.com/main.nfs?a=ibphoenix&s=1155387578:153600&page=ibp_60_sqlref Referenz-Dokumentation]
*[http://www-306.ibm.com/software/data/db2/ IBM DB2]
**[http://www-306.ibm.com/software/data/db2/udb/support/manualsv9.html IBM DB2 9 Manuals]
*[http://www.mimer.com/ Mimer SQL]
**[http://developer.mimer.com/documentation/html_92/Mimer_SQL_Engine_DocSet/Mimer_SQL_Engine.htm Mimer SQL 9.2]
*[http://www.microsoft.com/sql/default.mspx MSSQL]
**[http://msdn.microsoft.com/library/en-us/tsqlref/ts_tsqlcon_6lyk.asp SQL Server 2000]
**[http://msdn2.microsoft.com/en-us/library/ms189826.aspx SQL Server 2005]
*[http://www.mysql.com/products/database/ MySQL]
2006-12-07 19:34:29 +01:00
**[http://dev.mysql.com/doc/refman/4.1/en/sql-syntax.html MySQL 3.23, 4.0, 4.1], [http://dev.mysql.com/doc/refman/5.0/en/sql-syntax.html MySQL 5.0], [http://dev.mysql.com/doc/refman/5.1/en/sql-syntax.html MySQL 5.1], [http://dev.mysql.com/doc/refman/5.1/en/functions.html Funktions-Referenz]
2006-12-07 18:26:07 +01:00
2006-12-07 18:00:36 +01:00
*[http://www.oracle.com/database/index.html Oracle]
**[http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/toc.htm Oracle 10.2]
*[http://www.postgresql.org PostgreSQL]
2008-01-11 16:54:23 +01:00
**[http://www.postgresql.org/docs/7.4/static/sql-commands.html PostgreSQL 7.4], [http://www.postgresql.org/docs/8.0/static/sql-commands.html PostgreSQL 8.0], [http://www.postgresql.org/docs/8.1/static/sql-commands.html PostgreSQL 8.1], [http://www.postgresql.org/docs/8.2/static/sql-commands.html PostgreSQL 8.2],
[http://www.postgresql.org/docs/8.3/static/sql-commands.html PostgreSQL 8.3]
2006-12-07 18:00:36 +01:00
*[http://www.sqlite.org/ SQLite]
2006-12-07 19:34:29 +01:00
**[http://www.sqlite.org/lang.html Referenz-Dokumentation], [http://www.sqlite.org/pragma.html Pragma-Dokumentation]
2006-12-07 18:00:36 +01:00
*[http://www.sybase.com/products/informationmanagement Sybase]
**[http://infocenter.sybase.com/help/index.jsp Referenz-Dokumentation]