Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • standard Monitoring – 1 Oracle
  • Find nth max and min. Oracle
  • sqlnet.ora paramters Oracle
  • ORACLE_SID in sqlplus Oracle
  • find the files that are 1 day old. Linux/Unix
  • move_arch_files.ksh Linux/Unix
  • Facts about SCN and Rollback Segment Oracle
  • PHP code to add WordPress posts in bulk programmatically PHP/MYSQL/Wordpress
  • TRUNCATE Privs Oracle
  • Adding Datafile on Primary Server and Impact on Standby Server Oracle
  • Find Command Linux/Unix
  • Processes parameter and its dependencies on OS kernel parameters Linux/Unix
  • 272332.1 CRS 10g Diagnostic Collection Guide Oracle
  • Pending Distributed Transations Oracle
  • Space padding in korn shell Linux/Unix

Year: 2023

Add new columns in dataframe

Posted on 30-Sep-202301-Oct-2023 By Admin No Comments on Add new columns in dataframe

from pyspark.sql.functions import col, lit# File location and typefile_location = “/FileStore/tables/sales_data_part1.csv”file_type = “csv”# CSV optionsinfer_schema = “false”first_row_is_header = “true”delimiter = “,”# The applied options are for CSV files. For other file types, these will # be ignored.df = spark.read.format(file_type) .option(“inferSchema”, infer_schema) .option(“header”, first_row_is_header) .option(“sep”, delimiter) .load(file_location)display(df)# Adding new column with and with default values. #…

Read More “Add new columns in dataframe” »

Python/PySpark

Getting started with notebook

Posted on 30-Sep-202330-Sep-2023 By Admin No Comments on Getting started with notebook

# Databricks notebook source   %sqlcreate database if not exists abcdb   %sqluse abcdb   %sqlcreate table student (id int , name string)   %sqlinsert into studentselect 1 as id, ‘user1’ as name   %sqlselect * from student   spark.sql(“create database if not exists xyzdb”)spark.sql(“use xyzdb”)   # Use three double quotes (“””) if SQL…

Read More “Getting started with notebook” »

Python/PySpark

Read CSV file using PySpark

Posted on 30-Sep-202330-Sep-2023 By Admin No Comments on Read CSV file using PySpark

from pyspark.sql.functions import col   # File location and type file_location = “/FileStore/tables/sales_data_part1.csv” file_type = “csv” # CSV options infer_schema = “false” first_row_is_header = “true” delimiter = “,” # The applied options are for CSV files. For other file types, these will be ignored. df = spark.read.format(file_type)   .option(“inferSchema”, infer_schema)   .option(“header”, first_row_is_header)   .option(“sep”,…

Read More “Read CSV file using PySpark” »

Python/PySpark

Read CSV File using Python

Posted on 30-Sep-202330-Sep-2023 By Admin No Comments on Read CSV File using Python

# Databricks notebook source import pandas as pd # preapre dataframe df_h=pd.read_csv(“https://people.sc.fsu.edu/~jburkardt/data/csv/zillow.csv”) #Print dataframe df_h #define custom columns columns = [“Srno”, “SQFT”, “BR”, “Baths”, “Zipcode”, “YearBuilt”, “ListPrice”] df_h=pd.read_csv(“https://people.sc.fsu.edu/~jburkardt/data/csv/zillow.csv”, header=None, names=columns) #Print dataframe df_h # show top 10 rows df_h.head(10) # show last 10 rows df_h.tail(10) #Print dataframe df_h #Drop non-needed columns, column names are case…

Read More “Read CSV File using Python” »

Python/PySpark

Creating never expiring DB user accounts in Oracle

Posted on 14-Sep-202314-Sep-2023 By Admin No Comments on Creating never expiring DB user accounts in Oracle

DB Users are required to reset the password periodically for better security. For some service accounts,  we need to make sure the password does not expire and does not impact the application. For this purpose, we need to update that user’s Profile. Each Profile has multiple security settings that controls Password_life_time, password_reuse_time, password_reuse_max  settings. These…

Read More “Creating never expiring DB user accounts in Oracle” »

Oracle, SQL scripts

Convert multiple rows to single column

Posted on 13-Sep-202313-Sep-2023 By Admin No Comments on Convert multiple rows to single column

Converting rows to single column: create table emp ( empno number, empname varchar2(100), deptno number); insert into emp values( 1, ’emp1′, 10); insert into emp values( 2, ’emp2′, 20); insert into emp values( 3, ’emp3′, 30); insert into emp values( 4, ’emp4′, 10); insert into emp values( 5, ‘paresh’, 30); insert into emp values( 6,…

Read More “Convert multiple rows to single column” »

Oracle, SQL scripts

Find all users who have DML privileges

Posted on 05-Sep-202305-Sep-2023 By Admin No Comments on Find all users who have DML privileges

Run following query as sysdba. alter session set nls_date_format=’DD-MON-RRRR:HH24:MI:SS’; alter session set nls_date_format=’DD-MON-RRRR:HH24:MI:SS’; select username, created, account_status /* Users who granted role with DML privs */ from dba_users where oracle_maintained = ‘N’ and username in (select grantee from dba_role_privs where granted_role in (select role from dba_roles where role in (select GRANTEE from dba_tab_privs where privilege…

Read More “Find all users who have DML privileges” »

Oracle, SQL scripts

Oracle GoldenGate lag monitoring shell script

Posted on 12-Jun-202318-Jun-2023 By Admin No Comments on Oracle GoldenGate lag monitoring shell script

Following script will be useful for tracking Oracle GoldenGate replicat process and related lag. This script will generate output on standard screen.  You can redirect it using file redirection to logfile or other locations.  while true do <goldengate home directory>/ggsci <<EOF > test.out info all exit EOF lag=`cat test.out | grep TESTREPLICAT | awk ‘{print…

Read More “Oracle GoldenGate lag monitoring shell script” »

Linux/Unix, Oracle, shell

Find which sessions is accessing object that prevent your session to have exclusive locks in Oracle

Posted on 11-Jun-202311-Jun-2023 By Admin No Comments on Find which sessions is accessing object that prevent your session to have exclusive locks in Oracle
Find which sessions is accessing object that prevent your session to have exclusive locks in Oracle

If you want exclusive lock on any table, you need to make sure that no other session is  accessing it. This happens when you want to run DDL or any ALTER statements, that internally needs exclusive lock. Following script will to find the blocker session and provide killing statement for clearing locks.  col owner format…

Read More “Find which sessions is accessing object that prevent your session to have exclusive locks in Oracle” »

Oracle, SQL scripts

How to collect CPU usage on Linux using Shell script

Posted on 09-Jun-202309-Jun-2023 By Admin No Comments on How to collect CPU usage on Linux using Shell script

Following script will help to collect CPU based on on every SAMPLE_TIME. This will help to collect IDLE CPU our from “vmstat” and store them in a file. #Setup SAMPLE_TIME for cpu data collection interval SAMPLE_TIME=5 while true do x=`vmstat | grep -v procs | grep -v swpd | awk ‘{print $15}’` echo `date +”%m-%d-%y…

Read More “How to collect CPU usage on Linux using Shell script” »

Linux/Unix, shell

Posts pagination

1 2 Next

Categories

  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • Oracle (388)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (337)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • findinfo.sql (SQL for getting CPU and Active session info)27-May-2025
  • SQL Tracker by SID sqltrackerbysid.sql22-Apr-2025
  • How to connect to Oracle Database with Wallet with Python.21-Mar-2025
  • JSON/XML Types in Oracle18-Mar-2025
  • CPU Core related projections12-Mar-2025
  • Exadata Basics10-Dec-2024
  • Reading config file from other folder inside class24-Sep-2024
  • Python class import from different folders22-Sep-2024
  • Transfer SQL Profiles from One database to other database.05-Sep-2024
  • Load testing on Oracle 19C RAC with HammerDB18-Jan-2024

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • ipcs -l Linux/Unix
  • My Minimum Tuning Programs Oracle
  • How to Modify the statistics collection by MMON for AWR repository Oracle
  • Changing default shell Linux/Unix
  • Find Time Consuming SQL Statements in Oracle 10g Oracle
  • SQL Tracker by SID sqltrackerbysid.sql Oracle
  • Best approach for Oracle database patching sequence to latest/required patchset along with CPU/PSU/any-other-one-off patch ID 865255.1 Oracle
  • PLSQL Table Syntax 1 Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme