Teradata Commands

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

1)To Know Which database We r Working

select database

sel user,database

If you want to change your default database so that it is always payroll each time
you login, you use the MODIFY USER command.

Example

MODIFY USER td0001 AS DEFAULT DATABASE = payroll;

2)To know Available tables in Particular Database

SELECT * FROM dbc.tables WHERE databasename='xxxxxx'

EX

SELECT * FROM dbc.tables WHERE databasename='retail'

SELECT * FROM dbc.tables WHERE databasename='RETAIL_PROJECT_DB'


AND tablekind = 'T'

3) To get all table names in teradata

SELECT * FROM dbc.tables WHERE tablekind = 'T'

4) Display List Of databases

SELECT * FROM DBC . Databases

5) Display Current user info

sel * from dbc.users

6) Display all rights info for a user and database

select * from dbc.allrights where username='sree' and


databasename='sree'

HOW TO DROP USERS OR DATABASE ?....

DELETE DATABASE VinayProdb ALL;


MODIFY user VPROUSER AS DROP DEFAULT JOURNAL TABLE;

MODIFY DATABASE VPROJECT AS DROP DEFAULT JOURNAL TABLE;

7) Create Error table

Syn
-------

CREATE ERROR TABLE error_table_name FOR


database_name.table_name

EX
------

CREATE ERROR TABLE err_party FOR sree.party

8) For Delete Database

SYN
====
Delete database <database name>

9) To create Identity for particular column

CREATE TABLE tbl_emp


(id INTEGER GENERATED ALWAYS AS IDENTITY (START WITH
1001 INCREMENT BY 1 MINVALUE 0 MAXVALUE 1000000 NO
CYCLE),Name VARCHAR(20), Phone VARCHAR(10))

ins into tbl_emp values (1001,'ramesh','8712332222')


ins into tbl_emp values (1001,'suresh','8712332222')

sel * from tbl_emp

/* to display database info */


help database sreedb

/* to display Particular session info */


help session;

help 'sql'

create table test2


(
TID int,
TNM varchar(20),
PHONE varchar(20))

insert into test2 values (2,'SREE','+919556778906')


insert into test2 values (3,'RAJU',919704333455)
insert into test2 values (4,'RAjESH','+919704338904')
insert into test2 values (5,'RAKESH',+918880336426)

sel * from test2

data inserted in the above pic

After Update data will like below


Column Name Also Be Changed

You might also like