Oracle Cheat Sheet

1. Ping Oracle.

tnsping SID

2. Get the SID.

SHOW PARAMETER instance_name;

3. JDBC driver.

oracle.jdbc.OracleDriver

4. JDBC driver URL pattern.

jdbc:oracle:thin:@HOST:PORT:SID

5. Date greater than clause.

date_col > TO_DATE('2015-01-01','yyyy-MM-dd')

 


Sample ElasticSearch Queries

1. Query all.

GET http://localhost:9200/index/type/_search

2. Query by single value, using a query string.

GET http://localhost:9200/index/type/_search?q=firstName:John

3. Query by single term, using request body.

GET http://localhost:9200/index/type/_search
    {
        "query": {
            "term": { "firstName" : "John" }
        }
    }

4. Paging query.

GET http://localhost:9200/index/type/_search
    {
        "from" : 0,
        "size" : 10,
        "query" : {
            "term" : { "firstName" : "John" }
        }
    }

5. Pre-filter.

 GET http://localhost:9200/index/type/_search
    {
        "query": {
            "filtered": {
                "filter": {
                    "term": { "firstName" : "John" }
                }
            }
        }
    }

6. Pre-filters.

GET http://localhost:9200/index/type/_search
    {
        "query": {
            "filtered": {
                "filter": {
                    "and": {
                        "filters": [ {
                            "term": { "firstName": "John", "country": "US" }
                        } ]
                    }
                }
            }
        }
    }

7. Pre-filter terms.

GET http://localhost:9200/index/type/_search
    {
        "query": {
            "filtered": {
                "filter": {
                    "and": {
                        "filters": [ {
                            "term": { "firstName": "John" }
                        }, {
                            "terms": { "country": [ "US", "CA" ] }
                        } ]

8. Missing email filter.

GET http://localhost:9200/index/type/_search

    {
        "query": {
            "filtered": {
                "filter": {
                    "missing": { "field" : "emailAddress" }
                }
            }
        }
    }

9. Pre-filtered query.

GET http://localhost:9200/index/type/_search
    {
        "query": {
            "filtered": {
                "query": {
                    "term": { "firstName": "John" }
                },
                "filter": {
                    "term": { "country": "US" }
                }
            }
        }
    }

10. Nested filter.

GET http://localhost:9200/index/type/_search

    {
        "query": {
            "filtered": {
                "filter": {
                    "nested": {
                        "path": "person",
                        "filter": {
                            "term": { "person.country": "US" }
                        }
                    }
                }
            }
        }
    }

11. Nested and non-nested filter.

{
        "query": {
            "filtered": {
                "filter": {
                    "and": {
                        "filters": [ {
                            "term": { "firstName": "John" }
                        }, {
                            "nested": {
                                "path": "person",
                                "filter": {
                                    "term": { "person.country": "US" }
                                }
                            }
                        } ]
                    }
                }
            }
        }
    } 

Java Utilities

Here are some Java utilities (with common parameters) we use for troubleshooting Production issues.

Display a list of all Java processes.

>jps

Display a list of all Java processes with full command line information.

>jps -lmv

Print available jstat options.

>jstat -options

Display GC information for the given process id.

>jstat -gc {pid}

Create a thread dump, displayed on the console, for the given process id.

>jstack {pid}

Display heap summary for the given process id.

>jmap -heap {pid}

Display heap histogram for the given process id.

>jmap -histo:live {pid}

Create a heap dump in hprof format.

>jmap -dump:live,format=b,file=dump.hprof {pid}

Display available commands that can be sent to the Java process with the given id.

>jcmd {pid} help

Force a garbage collection.

>jcmd {pid} GC.run

Display uptime information.

>jcmd {pid} VM.uptime

Display performance information.

>jcmd {pid} PerfCounter.print

These utilities are great for scripting and headless environments. If you wish to work with graphical interface, check out VisualVM. Here’s a list of all the JDK Tools and Utilities.