Enlightensoft's Blog

Helping in your each step

  • Categories

  • Authors

Archive for the ‘Database’ Category

How to use/connect database from mysql command prompt

Posted by Pankil Patel on May 17, 2012

Note: Please make sure that you have checked the command prompt feature during mysql installation.

Step 1: type “cmd” into your run window of your OS

Step 2: type below command into your cmd terminal

>mysql -h localhost -u root -p

it will ask for passwod like below

Enter password: ****

you need to give password and after that press enter key.

Step 3: now it will give mysql> terminal initial, When you see mysql> it means from a MySQL prompt after successful logging into MySQL using “localhost” as a host and “root” as a user.

Step 4: Now perform any database commands into your database by creating / selecting your database.

Ex:

mysql> create database mytest;
Query OK, 1 row affected (0.00 sec)

mysql> use mytest;
Database changed
mysql>

Posted in Database, MySQL | Leave a Comment »

Nth Highest record in Oracle

Posted by Pankil Patel on April 18, 2012

First solution:

nth highest record from Bv_Category table based on Indvl_Rank_Id

select * From
(
Select C.*, Dense_Rank() Over (Order By C.Indvl_Rank_Id Desc) Ranking From Bv_Category C
)
where Ranking = (nth index)

Example: Record with Second Highest Indvl_Rank_Id

select * From
(
Select C.*, Dense_Rank() Over (Order By C.Indvl_Rank_Id Desc) Ranking From Bv_Category C
)
where Ranking = 2

For more detail visit:

http://www.oratable.com/nth-highest-salary-in-oracle/

Second solution:

Example: Second Highest Indvl_Rank_Id

Select Min(Indvl_Rank_Id) From (
select * from (
Select Unique Indvl_Rank_Id From
Bv_Category
ORDER BY Indvl_Rank_Id DESC) where ROWNUM <= 2)

Posted in Database, Oracle | Tagged: , | Leave a Comment »

jPub Object Generation Command

Posted by Pankil Patel on January 11, 2012

set path=%path%.;C:\oracle\product\10.2.0\client_1\BIN;

set classpath=%classpath%;.;C:\oracle\product\10.2.0\client_1\sqlj\lib\runtime12.jar;C:\oracle\product\10.2.0\client_1\sqlj\lib\translator.jar;C:\oracle\product\10.2.0\client_2\jdbc\lib\ojdbc14.jar;c:\xmlparserv2.jar;C:\oracle\product\10.2.0\client_1\sqlj\lib\runtime12ee

jpub -url=jdbc:oracle:thin:@<HostName>:15000/<service name> -user=username/password -omit_schema_names -package=co.cc.enlightensoft.demo.vote.db.dto -sql=BV_OBJ_FIRM_ARRARY_TAB:UserDBDto -tostring=true -dir=C:\jpub

Posted in Database, Oracle | Leave a Comment »

Command to copy table in same database schema

Posted by Pankil Patel on April 8, 2011

create table ABC_COPY as select * from ABC;

Note: It will create new table ABC_COPY in same schema as table ABC, with all data in new table same as original table data.

But new table doesn’t having any constrains created as they are in original table.

You need to add/execute alter script yourself to add constrain in new table.

Posted in Database, Oracle | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.