Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

Monday, November 18, 2013

User names and tablespace names


Select all schema user names
select username from dba_users;


Select all tablespace names
select tablespace_name from dba_tablespaces;


Create a simple tablespace
CREATE TABLESPACE POOL_TS
  DATAFILE 'pool_ts.dat'
  SIZE 20M AUTOEXTEND ON;

Friday, November 1, 2013

Oracle append string to select query


Append in a select statement can be achieved via the || operator.

select 'Mr.' || name from employee e where e.sex = 'M'

select case when e.sex = 'M' then 'Mr.' else 'Ms.' end || name as salutation_name from employee e

Wednesday, October 6, 2010

Unlock account in Oracle Database (ORA-28000)

An oracle database account can get locked for several reasons. The most common reason is number of unsuccessful attempts. This typically give the following error :

ORA-28000: the account is locked

Account can be unlocked by logging in as 'sys' user and issuing the following command:

SQL> alter user scott identified by tiger account unlock;

Wednesday, December 5, 2007

MySQL convert or cast int to string

Suppose you have a table with 2 columns one int and other varchar. Now if you want to update varchar fields in all the records with the int value, use this query :

update table_name set varchar_Field = CAST(int_Field AS CHAR);

If you want to some text in addition to the int field, then use :

update table_name set varchar_Field = CONCAT(CAST(int_Field AS CHAR), 'sampleText');

Friday, October 19, 2007

Install of MySQL/PHPMyAdmin aka LAMP (Linux Apache MySQL PHP)

  • sudo apt-get install mysql-server
  • sudo apt-get install apache2
  • sudo apt-get install php5
  • sudo apt-get install php5-mysql
  • sudo apt-get install phpmyadmin

More information is available at the this link

Here is the link giving step by step instructions for getting mysql/apache/php and phpmyadmin working. Tells you how to set up mysql user too.

Wednesday, October 17, 2007

Python MySQL library support

Try the following at the python prompt.

>>> import _mysql
If the error is something like this :
Traceback (most recent call last):
    File "", line 1, in
        ImportError: No module named _mysql

Then try apt-get install python-mysqldb

Tuesday, August 14, 2007

How to modify Oracle LOBS/BLOBS/CLOBS

To modify a LOB,
SELECT id, blob FROM test FOR UPDATE

Note that you must use "FOR UPDATE" in the select statement or you will receive "ORA-22920: row containing the LOB value is not locked" when writing to the LOB.

The above lines are taken from the below link :
How to use Oracle LOBS/BLOBS/CLOBS