Code Comments

Code Comments

Tips and short tutorials on various programming technologies

Code Comments RSS Feed
 
 
 
 

Archive for SQL

Convert Results to Comma-delimited List in Oracle

Let’s say you are running a query and that there is a one-to-many relationship between one of the columns in one table and a column in another table. You could always retrieve the data from the database and process it using a regular programming language, but sometimes you want to do it all on the [...] Read more »

Copy Data From One Table to Another with SQL

Let’s say you have two tables in your SQL database. One is called Table1 and has columns called Column1 and Column2. And the other is called Table2 with columns of the same name. An easy way to copy from Table1 to Table2 would be with the following SQL statement.

INSERT INTO Table1
SELECT * FROM Table2

However, let’s [...] Read more »

How to Get Column Names from Database Table with Java

Let’s say you have a table in a SQL database and you want to discover the names of the columns from Java. One way to do this that is pretty straightforward is with the following code.

import java.sql.*;
 

 
public ArrayList<String> GetColumnNames(String tableName) throws Exception
{
DatabaseMetaData meta = _conn.getMetaData();
ResultSet rsColumns = [...] Read more »

Introduction to In-Memory Databases

I have been using a tool in programming projects for a couple years called SQLite. Essentially, this is a lightweight database with functionality similar to (but not as advanced as) relational database management systems like Oracle, SQL Server, or MySQL. One key difference is that SQLite databases reside either in memory or in a single [...] Read more »