On Seeing Information about the catalog #
#sql #sqlmetadata
--Find the tables
select table_name from user_tables
--Show the schemas that the current user has access to
select username from all_users
On Aliases #
#sqlselect #sql
using the as
keyword you can provide an alias to a column name in select
select first_name as FORENAME from tname
However it will output the alias in capitals regardless of the case. Using quotes will make it case sensitive.
select first_name as "forename" from tname
On Distinct #
#sqlselect #sql
--Gives distinct name, only the name column
select distinct name from animals
--Gives distinct name and id, only the name and id column
select distinct name,id from animals
On Virtual Columns #
#sqlselect #sql
select SERIAL_NUM || ' ' || BREED as ID from Animal
On Derived Columns #
Something Goes here FIll Later
On Functions #
you can select functions to be outputted as in avg(id) - average count(id) - count as in
select avg(rate) as average_rate from rates
--This return the average rate from rates
Subqueries #
They are enclosed within
Further Things done #
- Joins