What does the from content of this query mean? - sql

I am learning SQL now, I would like to know what is meant within the from, what is contained before and after the dot.
For example:
SELECT *
FROM apler.W_WORKED_INVOICES wwi
What does apler stand for?
The W_WORKED_INVOICES is the table, correct?

appler is database schema. Schema is defined in the Oracle documentation as a collection of logical data structures or schema objects.
W_WORKED_INVOICES is a table created in the appler schema

Related

What does pub.package mean

I have a dynamic SQL select statement that selects various fields from something named pub.package.customer.
I have never seen this before and I don't what it means or where it is getting the data from. If anyone has seen this or something similar before you knowledge would be greatly appreciated.
pub.package.customer
pub is database name
package is schema name
customer is table name
The full path of object is dot delimited name
Servername.Databasename.Ownername.Objectname
Here your object is customer table from which various fields are being used in your dynamic sql query.

Naming conventions in pgAdmin3

I am creating tables in the GUI of postgreSQL, PgAdmin3. There is an element that seems to be specious in the naming of the tables. The following is my fragmented comprehension of postgreSQL (I could be wrong if I am, please rectify). I am inserting tables in the database using the ETL tool Talend.
When there is only one schema in the database: No reference to the schema is mandatory
select * from tablename
When there is more than one schema in the database: Reference to the schema is mandatory and the reference to the schema is required in quotes
select * from "schema".tablename
There is something new I drifted upon yesterday and I do not know what might be causing pgAdmin to do this:
select * from "schema"."tablename"
I am not oblivious of the part that referencing to the specific schema is mandatory when there is more than one schema present in the same database and in quotes but why does one need to have the table name in quotes as well.

retrieve data type,size,precision and scale of postgresql columns

How to retreive data type, size, precision and scale of all columns of a particular table in postgresql with a single sql statement?
The table can have columns of the data types ( 'int2','int4','int8','float4','float8','numeric','varchar','char','date','timestamp'). If precision/scale are not applicable for a particular data type we can leave it as null.
I should not use INFORMATION_SCHEMA for this because though this schema is built-in we can drop this schema. SO i wrote code using this schema and if some how the customer drops this schema my code breaks. I just want to use pg_catalog tables/views.
The tables in information_schema are views on the system tables. If you use this command in psql, you will get the view definition that generates the columns view:
\dS+ information_schema.columns
You'll still have some work to do as the type casts to user-friendly outputs are also based on information_schema, but that shouldn't be too hard.
EDIT: In versions prior to 8.4, you have to use \d+, not \dS+

Oracle schema table name restrictions

I am looking into using JBoss 5.1.0GA on Oracle, and have seen this, warning that I should explicitly state the name of the schema into which the TIMERS table should be created, as Oracle doesn't permit the same table name to be used twice, even across schemas.
After reading this, I saw this question on StackOverflow, and would like some clarification about the hierarchy of objects in Oracle.
Suppose we have a single Oracle database server. Within this, we create two Databases - D1 and D2. Inside each database, we create two schemas - S1 and S2. Inside each schema on each database, we create a single table - T1 through to T4:
+-D1
| +---S1
| | +---T1
| +---S2
| +---T2
+-D2
+---S1
| +---T3
+---S2
+---T4
Am I correct in thinking that if I then add another table called T1 inside D1/S2, it will not work because the table names must be unique within the schemas, and T1 already exists in D1/S1, but if I add T1 to either D2/S1 or D2/S2 it will be fine because the two tables named T1 are in different databases?
I have a nasty feeling that my understanding of Oracle schemas is flawed (it is not a database I have used much before) so I'm sorry if I'm asking stupid questions.
Thanks in advance
Rich
the database hierarchical level doesn't exist in Oracle: an instance (set of processes) can only have one database (set of files) mounted at most. Inside a database you will find schemas which are also the same as users in Oracle.
Each schema has an independent namespace, e.g. schemas S1 and S2 can both have a table named T1 in the same database. You would specifically access these tables by using their owner as a prefix: S1.T1 and S2.T1.
Some objects don't have an owner (or their owner is PUBLIC) : Public synonyms and directories for example. The name of these objects will have to be unique in a database obviously. Use public synonyms wisely (=sparingly in my opinion) to avoid name collisions.
As far as Oracle goes, you can have the same table name in two different schemas. There may be something specific to the JBoss usage that you were reading about, but it is not an Oracle limitation.

How do you port a SqlServer database to MySQL?

I have a SqlServer db that I would like to port to MySQL. What's the best way to to this. Things that need to be ported are:
Tables (and data)
FileStream → MySQL equivalent?
Stored Procedures
Functions
Data types are relatively similar.
There is no equivalent to FileStream in MySQL - the files must either be stored as BLOBs, or on the file system while the path is stored in the database.
Migrating away from TSQL means:
There's no WITH clause in MySQL - it will have to converted into a derived table/inline view
There's no TOP syntax - these have to be converted to use LIMIT
There's no ranking/analytic functionality in MySQL - can't use ROW_NUMBER, RANK, DENSE_RANK or NTILE. See this article for alternatives.
MySQL views have notoriously limited functionality:
The SELECT statement cannot contain a subquery in the FROM clause.
The SELECT statement cannot refer to system or user variables.
Within a stored program, the definition cannot refer to program parameters or local variables.
The SELECT statement cannot refer to prepared statement parameters.
Any table or view referred to in the definition must exist. However, after a view has been created, it is possible to drop a table or view that the definition refers to. In this case, use of the view results in an error. To check a view definition for problems of this kind, use the CHECK TABLE statement.
The definition cannot refer to a TEMPORARY table, and you cannot create a TEMPORARY view.
Any tables named in the view definition must exist at definition time.
You cannot associate a trigger with a view.
As of MySQL 5.0.52, aliases for column names in the SELECT statement are checked against the maximum column length of 64 characters (not the maximum alias length of 256 characters).
Dynamic SQL will have to be converted to use MySQL's Prepared Statement syntax
A guide/article with some useful tips is available on the official MySQL dev site.
This is not for the faint of heart. Here is an article that explains what you are in for:
http://searchenterpriselinux.techtarget.com/news/column/0,294698,sid39_gci1187176,00.html