Postingan

Menampilkan postingan dengan label database

How to do Pagination in Oracle Database - SQL Query With Example

Gambar
Many time we need SQL query which returns data page by page i.e. 30 or 40 records at a time, which can be specified as page size. In fact, Database pagination is a common requirement of Java web developers, especially dealing with the largest data sets.  In this article, we will see how to query Oracle 10g database for pagination or how to retrieve data using paging from Oracle. Many Java programmer also uses display tag for paging in JSP which supports both internal and external paging. In case of internal paging, all data is loaded into memory in one shot and display tag handles pagination based upon page size but it only suitable for small data where you can afford those many objects in memory. If you have hundreds of row to display than its best to use external pagination by asking the database to do pagination. In pagination, ordering is another important aspect which can not be missed. It’s virtually impossible to sort large collection in Java using Comparator or Comparable b...

How to Remove Leading/Trailing White Space from a String in SQL Server? LTRIM, RTRIM Example

Gambar
Unlike Java, Microsoft SQL Server 2008, 2012, 2014,  and even the latest version don't have a built-in trim() function, which can remove both leading and trailing space from the given String. But, SQL Server does have two built-in functions LTRIM() and RTRIM() to remove leading and trailing space. The LTRIM() function removes space from the left side of String so you can use it to get rid of leading space, while RTRIM() removes white-space from the right side of String so you can use it to delete trailing space. You can even combine these two methods to create your own TRIM() method in SQL SERVER e.g. LTRIM(RTRIM(column)) will act as a TRIM() method because it removes both leading and trailing space . How to use LTRIM() and RTRIM() in SQL Server You can use LTRIM() and RTRIM function like any other built-in function. You can apply it to a value or a column in SQL query. Here is a couple of example of LTRIM function in Microsoft SQL Server database: // variable declaration DECL...

How to use EXISTS Clause in SQL? A Real World SQL Query Example using EXISTS

Gambar
Hello Guys, you might have heard about how useful the EXISTS clause is helpful in writing sophisticated queries. Still, at the same time, I have also seen that many programmers struggle to understand and use EXISTS and NOT EXISTS clause while writing SQL queries.  If you are one of them, then you have come to the right place. Today you will learn how to use the EXISTS clause in SQL by picking up a real-world example and an excellent SQL exercise from the LeetCode. Suppose that a website contains two tables, the Customers table, and the Orders table. Can you write an SQL query to find all customers who have never ordered anything ? To solve this problem, you need to first think about data. For example, if a customer has never ordered anything means there won't be any record for him on the Orders table. Good job, half of the task is done. Now the second half is how do you check if there is a record or not for a particular customer?  That's where EXISTS and NOT EXISTS clause will...

5 Websites to Learn SQL Online for FREE

Gambar
The SQL is one of the most important skills for any programmer be it a Java, C++, Python, JavaScript, or Ruby developer. Almost 95% of the Java applications use a relational database in their back-end and almost all web applications use the database. In recent years, one of the most common way to learn any programming skill is online, at your comfort of the office or home and SQL is no different. Learning SQL online has another advantage of a quick head start because you don't need to install a database and create tables to write some SELECT queries. The installation and setup is definitely a tough part for beginners and I have gone through that pain every time I have to learn a new database. Anyway, once you start writing queries and seeing the result, you feel that confidence needed to go to next level, which involves downloading and installing a free copy of popular databases like MySQL, SQL Server or Oracle in your machine. From my experience, I can say that SQL is easy to lear...

Top 5 NoSQL Databases Programmers Should Learn in 2020

Gambar
Though it's not mandatory for Java or Web developers to learn the NoSQL database, the world is moving in that direction, and both Java and Web developer should be familiar with NoSQL databases. If you are wondering what NoSQL database is means, then here is a quick overview. A NoSQL database refers to non SQL, non-relational, or not only SQL) that provides a mechanism for storage and retrieval of data, which is modeled in means other than the tabular relations used in relational databases. With Spring 5 introducing Web-Flux, a new non-blocking web framework, the use of a NoSQL database will only grow, but the big question is which NoSQL database to start with? There are many popular NoSQL options available, like Apache Cassandra, MongoDB, Redis, and Couchbase. Well, it totally depends upon your project; if it's using Cassandra, then you probably need to learn Cassandra, and if it is using MongoDB, then you probably need to learn MongoDB. But if you are a technical or a solutio...

Top 5 Courses to learn PostgreSQL in 2020 - Best of Lot

Gambar
PostgreSQL is one of the most popular databases after the big three - Oracle, SQL Server, and MySQL. PostgreSQL is commonly known as Postgres and is often referred to as the world's most advanced open source database. If you are looking to learn PostgreSQL in 2020 and looking for some useful resources like books, tutorials, and courses then you have come to the right place. In this article, I am going to share some of the best PostgreSQL online courses for beginners. These courses will cover topics ranging from installations to writing basic queries and retrieving data from tables. you will also explore the logic of SQL Joins, and a few best practices which are essential while working in real-world, production PostgreSQL database. For those who don't know what PostgreSQL is and why you should learn it, let me give you some basic introductions. PostgreSQL is an open-source object-relational database management system (ORDBMS), which was developed at the University of California,...

Top 5 Courses to Learn MongoDB NoSQL Database in 2020 - Best of Lot

Gambar
MongoDB is one of the leading NoSQL databases and it was on my radar for a long time but I never get a chance to learn or work on it, but Recently I got an opportunity to use MongoDB for one of our projects and I learned a lot on the way. In this article, I will introduce MongoDB and how to learn MongoDB so that you can use it in your project. In this article, I will share some of the online courses which I have taken to understand everything up to the basic CRUD (Create, Retrieve, Update, Delete) operations on MongoDB. I have also read a couple of books and followed some tutorials but these courses were my main source to learn Mongo DB. As you may already know that, MongoDB is a NoSQL database framework. NoSQL Databases are very different from traditional Relational Databases management systems (RDBMS) like Oracle, SQL Server, MySQL, or PostgreSQL. A Relational database has a specific pre-defined schema, tables, columns, constraints, type of fields, triggers, and so on, but in the NoS...

6 Free Database and SQL Courses for Beginners - Best of Lot

Gambar
Hello guys, we are already in the first week of New year and everyone is talking about their goals to improve them as a better person, a better programmer, or get better health. If you have also made your goal and one of them is to improve your SQL skill then you have come to the right place because I am going to share some of the free courses to learn and master SQL this year. As you already know, SQL is one of the essential skills and much more important than any fancy library or framework you are thinking to learn.  If you ask me which two skill every programmer should have, I would say SQL and UNIX, these two have survived for a long time and will survive for many coming decades. SQL is also very interesting, once you get a hang of it, you would love to write queries and analyzing the performance of your queries. Even though SQL is so important and many programmers realize this, I have found that a lot more programmer just doesn't spend much time to improve their SQL skills. Th...

30 Examples of MySQL Commands in Linux

Gambar
Here is my list of some of the most usefulMySQL commands which I have used in my day to day life while working with MySQL database in Linux. This comes straight from my notes so you may not find a lot of documentaries around it but they all are very useful. If you need to know more about any command you can always drop a note or look into resources I have shared at the end of this article. If you need a course to start learning MySQL from scratch, I recommendThe Ultimate MySQL Bootcamp on Udemy, one of the most comprehensive courses on MySQL for beginners. You can also buy in just $10 which is very cost-effective to learn a useful skill like MySQL. 1. For Checking Wheather MySQL Server is running on Linux or not ------------------------------------------------------------- $ ps -auxwww | grep mysql If it returns any row then MySQL server is running otherwise no. You can also check the output to verify its actually the MySQL server itself and not any other script which has MySQL in its ...

Top 4 Books to learn Oracle PL/SQL Programming - Best, Must Read

Gambar
In last summer, I had to work on a Java project which was using the Oracle database at their backend. The project was a mix of Java code with Oracle PL/SQL stored procedures, where Stored procedures were quite big and complex to read. I had not worked on Oracle for a couple of years and almost forget whatever I knew before. So, to revise, update and re-learn and I looked over some of the books and online courses like T he Complete Oracle SQL Certification Course which helped me a lot. In my quest to revise and re-learn Oracle SQL, I also find lots of their used books on Oracle PL/SQL which are both interesting to read as well as provides a great wealth of information to any programmer. Today, I am going to share those books with you.  As a Java developer, I had worked on a project with no active DBA for the team and you as a programmer have a responsibility to create, update and understand existing PL/SQL stored procedure. What this means is, you need to know the PL/SQL, if n...

SQL GROUP BY and HAVING Example - Write SQL Query to find Duplicate Emails - LeetCode Solution

Gambar
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Email   | +----+---------+ | 1  | a@b.com | | 2  | c@d.com | | 3  | a@b.com | +----+---------+ For example, your query should return the following for the above table: +---------+ | Email   | +---------+ | a@b.com | +---------+ Note: All emails are in lowercase. SQL query to find duplicate values in a Column - Solution Here are three ways to solve this problem in SQL query, first by using group by clause, second by using self-join and then third by using subquery with exists clause.  While I agree that this problem can be solved in a different way, but it is also a perfect example of how you can use the SQL GROUP BY and HAVING clause . But, if you are new to SQL world, it's better to start with a comprehensive SQL course like The Complete SQL Bootcamp  course by Jose Portilla on Udemy. That will help you to learn SQL better and quicker, and these kinds of a...

Database Website to Run and Practice SQL Query Online for FREE - SQLFiddle

Gambar
Other day, I was looking for a website to execute SQL query online, since I have uninstalled Microsoft SQL Server because of memory and CPU constraint and I don't want to install it again, just for executing another query. Also, installing database is pain, it takes time and eats up lots of resources e.g. RAM memory, CPU etc; Given so many database to work with e.g. Oracle, MySQL, Sybase, PostgreSQL and SQLLite, it's not really possible to have all of them in your poor laptop. Fortunately my search leads be to this wonderful site called SQLFiddle, this is what exactly I wanted. This site offers support for lot of popular databases, allows you to build your database schema online and execute SQL query on the fly. I couldn't have asked more, It's a great resource to learn and practice SQL queries online . Apart from many sweet features, it also allows you to share your problem with the community. If you are writing a complex query and stuck in middle, looking for help, yo...

10 Example Queries of SQL Select Command

Gambar
The Select command in SQL is one of the most powerful and heavily used commands. This is I guess the first command anyone learn in SQL even before CREATE which is used to create a table in SQL. SELECT is used in SQL to fetch records from database tables and you can do a lot many things using Select. For example, you can select all records, you can select few records based on the condition specified in WHERE clause, select all columns using the wild card (*) or only selecting a few columns by explicitly declaring them in a query. In this SELECT SQL command tutoria l, we will see some examples of select command or Select Statement and will write SQL queries to demonstrate the result. We will use the following table and data for our SQL query examples, one table represent Stocks listed in various market and another table contains Details of market e.g. Country. MySQL is my favorite RDBMS and great for learning purpose you can download MySQL and start working on it. My suggestion is to...