Tag Info

Hot answers tagged

35

I've swapped between working on Oracle and SQL Server over the past few years, and wrote a blurb on going the other way here. There are a number of idiomatic and architectural differences, and various bits of terminology get used differently by the vendor and developer/DBA communities surrounding each product. Physical architecture SQL Server organises ...


34

One of the biggest benefit of using a materialized view is that Oracle takes care of keeping the data in sync. If you have a separate aggregate table, you are responsible for keeping the data synchronized. That generally requires a reasonable amount of code and a decent amount of testing and most organizations manage to make mistakes that leave holes that ...


33

With GROUP BY b,a the tuples (null, 1), (1,1), (2,1) and (17,1) would end up in four different groups. With GROUP BY coalesce(b,a) the tuples (null,1), (1,1), (2,1) and (17,1) would end up in the same group. If you want the "conditional" grouping, then yes, the version with coalesce is probably what you want.


31

Oracle and SQL Server have a number of architectural and idiomatic differences, and several key bits of terminology are used differently in the documentation. It's quite a few years since I did this, but some of the major idiomatic differences are: Oracle has no direct equivalent to tempdb. Global temp tables are persistent entities and you do not create ...


27

SYS: automatically created when Oracle database is installed automatically granted the DBA role has a default password: CHANGE_ON_INSTALL (make sure you change it) owns the base tables and views for the database data dictionary the default schema when you connect as SYSDBA Tables in the SYS schema are manipulated only by the database. They should never ...


26

Strictly, yes, the FROM clause of a SELECT statement is not optional. The syntax for SQL-99 details the basic SELECT statment, and the FROM clause doesn't have any square brackets around it. That indicates the standard considers it non-optional: SELECT [ DISTINCT | ALL ] {Column expression [ AS name ]} [ ,... ] | * FROM <Table reference> [ ...


25

sqlplus user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname.network)(Port=1521))(CONNECT_DATA=(SID=remote_SID))) Maybe, and this might be dependant on the command line environment you're using, you need to quote the string, something like sqlplus ...


21

From Wikipedia: The DUAL table is a special one-row table present by default in all Oracle database installations. It is suitable for use in selecting a pseudocolumn such as SYSDATE or USER. The table has a single VARCHAR2(1) column called DUMMY that has a value of 'X'. Thus, the dual table is a way to perform operations against what amounts to be an ...


21

It would seem that Oracle at one time had plans to give a different definition to VARCHAR than to VARCHAR2. It has told customers this and recommends against using VARCHAR. Whatever their plans were, as of 11.2.0.2 VARCHAR is identical to VARCHAR2. Here is what the SQL Language Reference 11g Release 2 says: Do not use the VARCHAR data type. Use the ...


21

Currently, the two are synonymous. VARCHAR is an ANSI standard data type but Oracle's implementation of the VARCHAR data type violates the ANSI standard by considering the empty string to be NULL (Oracle's implementation predates the ANSI standard). As Leigh points out, Oracle has stated that the semantics of the VARCHAR data type may change in the future ...


21

First impressions Depending on your performance requirements, 100TB is a fairly aggressive data volume. If you want Oracle, you should check out their Exadata systems. Also, take a look at the offerings from Netezza or Teradata. With that volume of selects you might want to look at an OLAP based front end or at least fairly aggressive use of ...


19

Oracle's Data Modeller can reverse-engineer from an existing database. They were charging for it at one time, but it is now free to use.


18

Use a common table expression (CTE) and a windowing/ranking/partitioning function like ROW_NUMBER. This query will create an in-memory table called ORDERED and add an additional column of rn which is a sequence of numbers from 1 to N. The PARTITION BY indicates it should restart at 1 every time the value of Val changes and we want to order rows by the ...


17

Assuming you can't change your structure, you can use a CASE statement in your ORDER BY: ORDER BY case cat when 'mgr' then 1 when 'dev' then 2 else 3 If you can change your structure, however, you can create a Category table including the category code and a ranking, join your sample table to the Category table and sort by this ranking.


17

You need to recreate the control file This post by Kaunain Ahmed describes the necessary steps: do: alter database backup controlfile to trace; extract the "create controlfile" command from the background-dump-destination tracefile. shutdown the DB. Change the DB-Name in your init.ora and change the init.ora Change the SID in the ...


17

Realistically, the requirement is crazy. Like all great crazy ideas, however, it is probably based on a nugget of potential reasonableness taken far out of context by people that have no understanding of the underlying rationale. It can be reasonable to design a database schema such that no NULL values are allowed. If you do that, however, you are ...


16

No, partitioning allows some table scans to be restricted to a particular partition. Indexes tend to be useless if you will be returning more that 2 to 4 percent of the table's data. If your selection criteria allows the query to be localized to particular partition, then the other partitions won't need to be scanned. It might be possible for the ...


16

These views are helpful for working with DB links in Oracle: DBA_DB_LINKS - All DB links defined in the database ALL_DB_LINKS - All DB links the curernt user has access to USER_DB_LINKS - All DB links owned by current user


15

The answer to your question can be found in the SQL Language Reference (excerpt follows). Creating Basic Tablespaces: Examples This statement creates a tablespace named tbs_01 with one data file: CREATE TABLESPACE tbs_01 DATAFILE 'tbs_f2.dbf' SIZE 40M ONLINE; It sound like you are new to Oracle databases. Oracle provides a wealth of ...


15

Oracle is not like MySQL in this. Like most other RDBMSs it comes with it's own built-in storage engine that cannot be exchanged for another.


15

All of the platforms you have mentioned can run close to zero data loss configurations. All of them could be deployed in a configuration that will fail. Platform choice is one part of the puzzle. It will be your implementation of the platform that determines whether or not your requirements are met. MySQL Cluster Oracle RAC PostgreSQL High Availability ...


15

Here is a demonstration of a_horse_with_no_name's excellent+1 answer. SQL> WITH Data AS ( 2 SELECT level, DECODE(Level,3,NULL,1) A 3 , DECODE(level,2,NULL,4,2,1) B 4 FROM dual connect by level <=5 5 ) 6 SELECT A, B, count(*) FROM Data GROUP BY B, A; A B COUNT(*) - - ---------- 1 1 2 1 1 1 2 ...


15

Because '2012/12/1' in the US is 11 months after the same string date in Europe. Allowing implicit conversions means you are at the mercy of location settings. If you can name a business where 11 months is an acceptable margin of error I'll be impressed.


14

Commants to the local instance execute on return. Multi-line commands to the server execute on semicolon Special commands as detailed in the SQL*Plus manual are the only ones that do not accept semi-colons. Wheras SQL Commands must end with a ; in order to be parsed by the server.


14

You can use regular expressions and regexp_replace to remove the duplicates after concatenation with listagg: SELECT Num1, RTRIM( REGEXP_REPLACE( (listagg(Num2,'-') WITHIN GROUP (ORDER BY Num2) OVER ()), '([^-]*)(-\1)+($|-)', '\1\3'), '-') Num2s FROM ListAggTest; This could be tidier if ...


14

The logic with 'A' and 'B' might be "hidden" behind a virtual column on which you could do the partitioning: alter session set nls_date_format = 'yyyy-mm-dd'; drop table tq84_partitioned_table; create table tq84_partitioned_table ( status varchar2(1) not null check (status in ('A', 'B')), date_a date not null, date_b ...


14

It will take marginally longer to generate the plan when there are more indexes to consider, but I doubt the difference would be measurably significant. The reasons for dropping an index does not list query performance. On the other hand, in general you shouldn't create indexes unless you know they will be used to make a query more efficient. From the ...


14

There are a few different approaches depending on the details of your batch process and why you're trying to view the uncommitted changes. 1) Oracle Workspace Manager is a tool that was originally designed to allow people developing Spatial applications to have the equivalent of extremely long-running transactions (i.e. transactions that may require ...


14

Oracle has a significantly higher barrier to entry than SQL Server. Does that make working with Oracle "harder" than SQL Server, well that depends on what is meant by "harder" and where you're setting the bar. I've very rarely encountered enterprise, Oracle backed systems, that didn't have dedicated Oracle DBAs/developers on the development team. I ...


14

How do you log onto courgette? Would that username identify you? You can check that by running select sys_context('userenv', 'os_user') from dual; The USERENV namespace can retrieve a lot of different information about the user and their environment. Find out more.



Only top voted, non community-wiki answers of a minimum length are eligible