MySQL indexing compared to SQL Server - sql

Does MySQL have a sysindexes table or am I just thinking of SQL Server? If not, is there an equivalent indexing feature within MySQL at all?

SYS tables are specifically SQL Server; the ANSI equivalent is INFORMATION_SCHEMA. Part of the reason SYS tables still exist on SQL Server is they sometimes include additional information not in the INFORMATION_SCHEMA tables...
On MySQL, you want to use INFORMATION_SCHEMA.STATISTICS:
SELECT *
FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_name = 'tbl_name'
AND table_schema = 'db_name'

InnoDB tables can definitely be indexed; not sure about the scope available with ISAM tables. The system information stuff is held in the information schema tables:
http://dev.mysql.com/doc/refman/5.0/en/schemata-table.html

Related

postgresql list all table fields information within a server

i'm in need to create VIEWS in postresql 9, to mimic oracle's col table,
basically it should display ALL table fields information from ALL table and ALL database on that server.
Can someone please point me a way? thanks.
Unlike Oracle, PostgreSQL implements the ANSI information_schema.
So Oracle's ALL_TAB_COLUMNS view corresponds to information_schema.columns
But this is only restricted to the current database. It is not possible to get this information for all databases - which is the same for Oracle, ALL_TAB_COLUMNS only shows the columns for the current database (=instance)
More details about the information_schema can be found in the manual
http://www.postgresql.org/docs/current/static/information-schema.html
I don't think is possible to get metadata information from a different database of that you've working right now.
To extract metadata from the current database, take a look here: http://www.alberton.info/postgresql_meta_info.html

Join Oracle and Sqlite tables

I have a local (read and write) sqlite database and a remote (read-only) oracle database. I use ODBC to access both DBs (I use an application to access the DBs by ODBC and query as such: EXECUTE-QUERY SQLITE "SELECT ..." or EXECUTE-QUERY ORACLE "SELECT ...") . I tried searching the net for a way to be able to perform one query joining tables from the 2 databases, but all I find is how to create a database link from oracle to other DBs but that doesn't help me because I have no write priviledges for the Orcale DB so creations of database links, databases, tables, views are not allowed in ORACLE, all I can do is query there. Is there an efficient way to do this with the restraints that I have?
How big are the tables in oracle? Given the limits of the access you have and the technology you are working with ( sqlite and oracle are worlds apart ), your best bet would probably be to export the tables from oracle into sqlite, then do your queries all within that.
Finally I installed Oracle express edition and created a database link to the other (read-only) oracle database. That worked great.

Utility to create sql statements

This is a question about Sql generation, not sql creating sql nor ORM.
Is their any cross database tools that will enable the creation of insert statements, e.g. for all the tables in particular schema or namespace. Say the namespace/schema is Aqua in Sql Server 2008, and your utility comes along and generates all possible insert statements for that namespace/schema. And it works on Oracle/MySql/Postgres/db2 etc.
Thanks.
Bob
ANSI SQL provides for a standard set of views under the schema INFORMATION_SCHEMA to provide metadata for just this purpose.
For generating simple table insert statement templates, all the information you really need to generate an insert statement for a given table is to execute this query:
select *
from INFORMATION_SCHEMA.COLUMNS
where TABLE_CATALOG = <my-db-name>
and TABLE_SCHEMA = <table-owner-schema>
and TABLE_NAME = <table-name>
order by ORDINAL_POSITION
in any database that supports the ANSI information schema views. That will give you one row for every column in the specified table, in the expected sequence.
Outside of the above, since no two vendors support the set of system tables with metadata, your pretty much SOL for a cross-database solution. And sadly, I don't believe the Oracle supports the ANSI information schema views.
Though you might look at Red Gate's product family: http://www.red-gate.com/

Listing all tables in a database

Is there a SQL command that will list all the tables in a database and which is provider independent (works on MSSQLServer, Oracle, MySQL)?
The closest option is to query the INFORMATION_SCHEMA for tables.
SELECT *
FROM INFORMATION_SCHEMA.Tables
WHERE table_schema = 'mydatabase';
The INFORMATION_SCHEMA is part of standard SQL, but not all vendors support it. As far as I know, the only RDBMS vendors that support it are:
MySQL
PostgreSQL
Microsoft SQL Server 2000/2005/2008
Some brands of database, e.g. Oracle, IBM DB2, Firebird, Derby, etc. have similar "catalog" views that give you an interface where you can query metadata on the system. But the names of the views, the columns they contain, and their relationships don't match the ANSI SQL standard for INFORMATION_SCHEMA. In other words, similar information is available, but the query you would use to get that information is different.
(footnote: the catalog views in IBM DB2 UDB for System i are different from the catalog views in IBM DB2 UDB for Windows/*NIX -- so much for the Universal in UDB!)
Some other brands (e.g. SQLite) don't offer any queriable interface for metadata at all.
No. They all love doing it their own little way.
No, the SQL standard does not constrain where the table names are listed (if at all), so you'll have to perform different statements (typically SELECT statements on specially named tables) depending on the SQL engine you're dealing with.
If you are OK with using a non-SQL approach and you have an ODBC driver for the database and it implements the SQLTables entry-point, you possibly might get the information you want!
pjjH
details on the API at:
http://msdn.microsoft.com/en-us/library/ms711831.aspx

sql select thru multiple postgres databases

is there a way to create a select statement that would retrieve data from multiple database in postgre?
i was thinking it would be something like this:
select * from dbname1.table1, dbname2.table2 where dbname1.table1.column1 = dbname2.table2.column1
Have a look at the "dblink" contrib module.
OTOH it's possible that you treat the databases in a PostgreSQL cluster as equivalent to the databases in... let's say MySQL. Which is incorrect - the PostgreSQL databases contain schemas and those are the equivalent of the databases in MySQL.
From here:
It is not possible to access more than
one database per connection.
Update: but see Milen's answer.