{"id":2130,"date":"2016-01-25T13:30:01","date_gmt":"2016-01-25T13:30:01","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=2130"},"modified":"2025-06-13T17:33:08","modified_gmt":"2025-06-14T00:33:08","slug":"moving-sql-database-content-to-couchbase","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/","title":{"rendered":"Moving SQL database content to Couchbase"},"content":{"rendered":"<p>Since the GA release of N1QL, we get a lot of questions about moving content from a SQL database to Couchbase. There are many different ways to do so. Today, I have chosen what is probably the simplest. I will transform each row of each table in a JsonDocument and store it in Couchbase. I will do my test with Postgres and their <a href=\"https:\/\/www.postgresqltutorial.com\/postgresql-sample-database\/\">sample dataset<\/a> inspired by MySQL <a href=\"https:\/\/dev.mysql.com\/doc\/sakila\/en\/\">Sakila sample<\/a>. I will use Java, but the guidelines presented here are applicable to other languages.<\/p>\n<h2>Connecting to a running SQL database<\/h2>\n<p>Since I am using Java, I will implement Spring Boot and their JDBC package, which handles the db connection for me. All I have to do is set up the right dependencies and properties to configure the <a href=\"https:\/\/docs.spring.io\/spring\/docs\/current\/javadoc-api\/org\/springframework\/jdbc\/core\/JdbcTemplate.html\">JdbcTemplate<\/a>. This object makes running a SQL query a breeze.<\/p>\n<h3>Dependencies<\/h3>\n<p>To make sure you have everything configured neatly and automatically you need the following dependencies:<\/p>\n<pre>\n<code>\n        dependencies {\n            compile \"org.springframework.boot:spring-boot-starter\",\n                    \"org.springframework.boot:spring-boot-starter-data-jpa\",\n                    \"org.postgresql:postgresql:9.4-1206-jdbc4\"\n        }\n<\/code><\/pre>\n<p>I am testing with Postgres but you could add any other driver supported by Spring JDBC. The spring-boot-starter-data-jpa will allow me to inject the preconfigured JdbcTemplate.<\/p>\n<h3>Configuration<\/h3>\n<p>To make sure the Spring framework finds your database, add the following properties to your configuration file (for example, src\/main\/resources\/application.properties).<\/p>\n<pre>\n<code>\n        spring.jpa.database=POSTGRESQL\n        spring.datasource.platform=postgres\n        spring.jpa.show-sql=true\n        spring.jpa.hibernate.ddl-auto=create-drop\n        spring.database.driverClassName=org.postgresql.Driver\n        spring.datasource.url=jdbc:postgresql:\/\/192.168.99.100:5432\/dvdrental\n        spring.datasource.username=postgres\n        spring.datasource.password=password\n<\/code><\/pre>\n<p>Of course you would need to fine-tune this according to the database you are using. Here I am using Postgres running on 192.168.99.100 with default port 5432. The name of the database I want to use is dvdrental.<\/p>\n<h3>Code<\/h3>\n<p>If everything is configured correctly you should be able to inject the JdbcTemplate and start querying your SQL DB.<\/p>\n<pre>\n<code>\n     @Autowired\n     JdbcTemplate jdbcTemplate;\n\n     @Override\n     public void doStuff() throws Exception {\n      String sql = \"SELECT id FROM table\";\n         Long id = jdbcTemplate.queryForObject(sql, Long.class);\n     }\n<\/code><\/pre>\n<h2>Connecting to Couchbase<\/h2>\n<p>My goal is to move content from a SQL database to Couchbase, so we also need a Couchbase connection.<\/p>\n<h3>Dependencies<\/h3>\n<p>Working with Couchbase on your Java project requires you to add the following dependency:<\/p>\n<pre>\n<code>\n   dependencies {\n        compile \"com.couchbase.client:java-client:2.2.3\"\n    }\n<\/code><\/pre>\n<p>This will give you access to the Couchbase<a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/4.1\/sdks\/java-2.2\/java-intro.html\"> Java SDK<\/a>.<\/p>\n<h3>Configuration<\/h3>\n<p>A basic Couchbase configuration requires basically three properties: one server IP address, a bucket name, and a bucket password. Doing this in a Spring Boot fashion would look like this:<\/p>\n<pre>\n<code>\n        @Configuration\n        public class Database {\n\n            @Value(\"${hostname}\")\n            private String hostname;\n\n            @Value(\"${bucket}\")\n            private String bucket;\n\n            @Value(\"${password}\")\n            private String password;\n\n            public @Bean Cluster cluster() {\n                return CouchbaseCluster.create(hostname);\n            }\n\n            public @Bean Bucket bucket() {\n                return cluster().openBucket(bucket, password);\n            }\n\n        }\n<\/code><\/pre>\n<p>The properties hostname, bucket, and password can be added directly to your application properties file.<\/p>\n<pre>\n<code>\n   # Hostnames, comma separated list of Couchbase node IP or hostname\n    hostnames: localhost,127.0.0.1\n    # Bucket name\n    bucket: default\n    # Bucket password\n    password:\n<\/code><\/pre>\n<h3>Code<\/h3>\n<p>With Couchbase, the equivalent granularity level of a database would be a bucket, which is where you store documents. With the previous configuration you can simply inject a bucket and start playing around.<\/p>\n<pre>\n<code>\n        @Autowired\n        Bucket bucket;\n\n        @Override\n        public void doStuff() throws Exception {\n            JsonDocument doc = bucket.get(\"key\");\n        }\n<\/code><\/pre>\n<h2>Tables<\/h2>\n<p>At this point you have a connection to a SQL database and Couchbase. Now we can start moving things around. The easiest way to move data is to consider each row of each table as a document.<\/p>\n<h3>Getting the SQL schema<\/h3>\n<p>Let\u2019s start by getting the schema of the database automatically using the JdbcTemplate. The interesting object here is <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/sql\/DatabaseMetaData.html\">DatabaseMetaData<\/a>, which can give us the complete structure of the database. The API is not the easiest to use, but at least it\u2019s documented.<\/p>\n<p>I will map the result of the DatabaseMetaData query to a list of Table and Column. I have created the following Java class to do so:<\/p>\n<pre>\n<code>\n         public class Table {\n\n            private String name;\n\n            private List<Column> columns = new ArrayList<Column>();\n\n            private String primaryKey;\n\n            public Table(String tableName) {\n             this.name = tableName;\n            }\n\n            public void setPrimaryKey(String primaryKey) {\n             this.primaryKey = primaryKey;\n            }\n\n            public void addColumn(String name, int type) {\n             columns.add(new Column(name, type));\n            }\n\n            public String getName() {\n             return name;\n            }\n\n            public List<Column> getColumns() {\n             return columns;\n            }\n\n            public String getPrimaryKey() {\n             return primaryKey;\n            }\n\n            public JsonObject toJsonObject() {\n             JsonObject obj = JsonObject.create();\n             JsonArray jsonColumns = JsonArray.create();\n             for (Column col : columns) {\n                    jsonColumns.add(col.toJsonObject());\n             }\n             obj.put(\"tableName\", name);\n             obj.put(\"primaryKey\", primaryKey);\n             obj.put(\"columns\", jsonColumns);\n             return obj;\n            }\n     }\n\n     public class Column {\n\n            private String name;\n\n            private int type;\n\n            public Column(String name, int type) {\n             this.name = name;\n             this.type = type;\n            }\n\n            public String getName() {\n             return name;\n            }\n\n            public int getType() {\n             return type;\n            }\n\n            public JsonObject toJsonObject() {\n             JsonObject obj = JsonObject.create();\n             obj.put(\"name\", name);\n             obj.put(\"type\", type);\n             return obj;\n            }\n\n     }       \n            \n<\/code><\/pre>\n<p>It\u2019s definitely not the most exciting code to write, but at the end you get a JSON representation of your SQL database tables.<\/p>\n<pre>\n<code>\n        public void getDatabaseSchema() throws Exception {\n         \/\/ get Database Medatadata objects to retrieve Tables schema\n        DatabaseMetaData databaseMetadata = jdbcTemplate.getDataSource().getConnection().getMetaData();\n            List<String> tableNames = new ArrayList<String>();\n            \/\/ Get tables names\n            ResultSet result = databaseMetadata.getTables(catalog, schemaPattern, tableNamePattern, types);\n            while (result.next()) {\n             String tablename = result.getString(3);\n             String tableType = result.getString(4);\n             \/\/ make sure we only import table(as oppose to Views, counter etc...)\n             if (!tablename.isEmpty() && \"TABLE\".equals(tableType)) {\n                    tableNames.add(tablename);\n                    log.debug(\"Will import table \" + tablename);\n             }\n            }\n            \/\/ Map the tables schema to Table objects\n            Map<String, Table> tables = new HashMap<String, Table>();\n            JsonObject tablesSchema = JsonObject.create();\n            for (String tableName : tableNames) {\n             result = databaseMetadata.getColumns(catalog, schemaPattern, tableName, columnNamePattern);\n             Table table = new Table(tableName);\n             while (result.next()) {\n                    String columnName = result.getString(4);\n                    \/\/ Maps to JDBCType enum\n                    int columnType = result.getInt(5);\n                    table.addColumn(columnName, columnType);\n             }\n             result = databaseMetadata.getPrimaryKeys(catalog, schemaPattern, tableName);\n             while (result.next()) {\n                    String columnName = result.getString(4);\n                    table.setPrimaryKey(columnName);\n             }\n             tables.put(tableName, table);\n             tablesSchema.put(tableName, table.toJsonObject());\n            }\n            JsonDocument schemaDoc = JsonDocument.create(tablesSchemaId, tablesSchema);\n            JsonDocument doc = bucket.upsert(schemaDoc);\n         }\n<\/code><\/pre>\n<h3>Content<\/h3>\n<p>Here\u2019s the fun part. This is where we start mapping a table row to a JsonDocument. The previous section puts us in a state where we can retrieve the name of all the tables. From one table name, we can create a SQL query that returns every row of the table.<\/p>\n<p>Spring has a mechanism that allows you to define a RowMapper. For each row returned by the query, you can return the object you want. Since I am using Couchbase, I want a <a href=\"https:\/\/docs.couchbase.com\/sdk-api\/couchbase-java-client-2.2.0\/com\/couchbase\/client\/java\/document\/JsonDocument.html\">JsonDocument<\/a>.<\/p>\n<p>Following is an implementation example. This RowMapper needs a Table object previously defined; therefore, we have to implement the mapRow method. There are several things we need to do here.<\/p>\n<p>The first task is to create a unique key. As rows are scoped by tables, some id can be exactly the same for rows in different tables. But documents are scoped by bucket, so we need to create a unique document key that reflects the row id and the table name. To keep track of where the document comes from, I will also add a _tableName field for the table name.<\/p>\n<p>Then, the exciting step comes from the type mapping. JSON supports fewer types than a SQL database, so we have some conversion to do here. This is what the getJsonTypedValue method does. It makes sure most JDBC type can be converted to a native JSON type (String, number, boolean, array, object, null). At the end, we have a JsonDocument that can be saved in Couchbase.<\/p>\n<pre>\n<code>\n        public class JSONRowMapper implements RowMapper<Document> {\n        \n        Table table;\n\n        public JSONRowMapper(Table table) {\n         this.table = table;\n        }\n\n        public JsonDocument mapRow(ResultSet rs, int rowNum) throws SQLException {\n         String id = table.getName() + \"::\" + rs.getString(table.getPrimaryKey());\n         JsonObject obj = JsonObject.create();\n         obj.put(\"_tableName\", table.getName());\n         for (Column col : table.getColumns()) {\n                Object value = getJsonTypedValue(col.type, rs.getObject(col.name), col.name);\n                obj.put(col.name, value);\n         }\n         return JsonDocument.create(id, obj);\n        }\n\n        public Object getJsonTypedValue(int type, Object value, String name) throws SQLException {\n         if (value == null) {\n                return null;\n         }\n         JDBCType current = JDBCType.valueOf(type);\n         switch (current) {\n         case TIMESTAMP:\n                Timestamp timestamp = (Timestamp) value;\n                return timestamp.getTime();\n         case TIMESTAMP_WITH_TIMEZONE:\n                Timestamp ts = (Timestamp) value;\n                JsonObject tsWithTz = JsonObject.create();\n                tsWithTz.put(\"timestamp\", ts.getTime());\n                tsWithTz.put(\"timezone\", ts.getTimezoneOffset());\n                return tsWithTz;\n         case DATE:\n                Date sqlDate = (Date) value;\n                return sqlDate.getTime();\n         case DECIMAL:\n         case NUMERIC:\n                BigDecimal bigDecimal = (BigDecimal) value;\n                return bigDecimal.doubleValue();\n         case ARRAY:\n                Array array = (Array) value;\n                Object[] objects = (Object[]) array.getArray();\n                return JsonArray.from(objects);\n         case BINARY:\n         case BLOB:\n         case LONGVARBINARY:\n                return Base64.getEncoder().encodeToString((byte[]) value);\n         case OTHER:\n         case JAVA_OBJECT:\n                \/\/ database specific, default to String value\n                return value.toString();\n         default:\n                return value;\n         }\n        }\n }\n        \n<\/code><\/pre>\n<p>With that RowMapper it makes things really easy. We can loop through the table\u2019s name, run the query, and save the results in Couchbase. Doing this in a synchronous fashion would look like this:<\/p>\n<pre>\n<code>\n        for (String tableName : tableNames) {\n         String sql = \"select * from \" + tableName + \";\";\n         List<JsonDocument&gt; rs = jdbcTemplate.query(sql, new JSONRowMapper(tables.get(tableName)));\n         if (!rs.isEmpty()) {\n             for (JsonDocument doc : rs) {\n               bucket.upsert(doc); \n                } \n         }\n        }\n        bucket.upsert(schemaDoc);\n<\/code><\/pre>\n<p>But I prefer the async version:<\/p>\n<pre>\n<code>\n   Observable.from(tableNames).flatMap(s -> {\n        String sql = String.format(\"Select * from %s;\", s);\n        return Observable.from(jdbcTemplate.query(sql, new JSONRowMapper(tables.get(s))));\n    })\n    \/\/ start by a jsonDocument containing the tables to be imported.\n    .startWith(schemaDoc).flatmap(doc -> asyncBucket.upsert(doc));\n<\/code><\/pre>\n<p>Here I am not using the full potential of Rx; take a look at <a href=\"https:\/\/github.com\/ldoguin\/couchbase-java-importer\/blob\/master\/src\/main\/java\/com\/couchbase\/devex\/ImportJsonToCouchbase.java\">this function<\/a> that writes a doc to Couchbase and handles timeout and error management.<\/p>\n<p>\u00a0<\/p>\n<p>For convenience, I have packaged all steps implemented and previously shown in a <a href=\"https:\/\/github.com\/ldoguin\/couchbase-java-importer\">single project<\/a>. All you have to do is make sure your properties file is configured right and run the importer:<\/p>\n<pre>\n<code>\n   $ .\/bin\/couchbase-java-importer myConfiguration.properties\n<\/code><\/pre>\n<p>Take a look at the <a href=\"https:\/\/github.com\/ldoguin\/couchbase-java-importer\/blob\/master\/README.md\">README<\/a> file for more information.<\/p>\n<h3>Conclusion<\/h3>\n<p>Today we have learn how to move SQL content to Couchbase, but there is still some work to do. Next time I will tell you how to move the SQL business logic to the application layer.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since the GA release of N1QL, we get a lot of questions about moving content from a SQL database to Couchbase. There are many different ways to do so. Today, I have chosen what is probably the simplest. I will [&hellip;]<\/p>\n","protected":false},"author":49,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1814,1815,1812],"tags":[1574],"ppma_author":[9023],"class_list":["post-2130","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-application-design","category-best-practices-and-tutorials","category-n1ql-query","tag-jdbc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Moving SQL database content to Couchbase - The Couchbase Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Moving SQL database content to Couchbase\" \/>\n<meta property=\"og:description\" content=\"Since the GA release of N1QL, we get a lot of questions about moving content from a SQL database to Couchbase. There are many different ways to do so. Today, I have chosen what is probably the simplest. I will [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-25T13:30:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T00:33:08+00:00\" \/>\n<meta name=\"author\" content=\"Laurent Doguin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ldoguin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"unstructured.io\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/moving-sql-database-content-to-couchbase\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/moving-sql-database-content-to-couchbase\\\/\"},\"author\":{\"name\":\"Laurent Doguin\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/c0aa9b8f1ed51b7a9e2f7cb755994a5e\"},\"headline\":\"Moving SQL database content to Couchbase\",\"datePublished\":\"2016-01-25T13:30:01+00:00\",\"dateModified\":\"2025-06-14T00:33:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/moving-sql-database-content-to-couchbase\\\/\"},\"wordCount\":932,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/moving-sql-database-content-to-couchbase\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"keywords\":[\"jdbc\"],\"articleSection\":[\"Application Design\",\"Best Practices and Tutorials\",\"SQL++ \\\/ N1QL Query\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/moving-sql-database-content-to-couchbase\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/moving-sql-database-content-to-couchbase\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/moving-sql-database-content-to-couchbase\\\/\",\"name\":\"Moving SQL database content to Couchbase - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/moving-sql-database-content-to-couchbase\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/moving-sql-database-content-to-couchbase\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2016-01-25T13:30:01+00:00\",\"dateModified\":\"2025-06-14T00:33:08+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/moving-sql-database-content-to-couchbase\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/moving-sql-database-content-to-couchbase\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/moving-sql-database-content-to-couchbase\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"width\":1800,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/moving-sql-database-content-to-couchbase\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Moving SQL database content to Couchbase\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/c0aa9b8f1ed51b7a9e2f7cb755994a5e\",\"name\":\"Laurent Doguin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b8c466908092b46634af916b6921f30187a051e4367ded7ac9b1a3f2c5692fd2?s=96&d=mm&r=g12929ce99397769f362b7a90d6b85071\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b8c466908092b46634af916b6921f30187a051e4367ded7ac9b1a3f2c5692fd2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b8c466908092b46634af916b6921f30187a051e4367ded7ac9b1a3f2c5692fd2?s=96&d=mm&r=g\",\"caption\":\"Laurent Doguin\"},\"description\":\"Laurent is a nerdy metal head who lives in Paris. He mostly writes code in Java and structured text in AsciiDoc, and often talks about data, reactive programming and other buzzwordy stuff. He is also a former Developer Advocate for Clever Cloud and Nuxeo where he devoted his time and expertise to helping those communities grow bigger and stronger. He now runs Developer Relations at Couchbase.\",\"sameAs\":[\"https:\\\/\\\/x.com\\\/ldoguin\"],\"honorificPrefix\":\"Mr\",\"birthDate\":\"1985-06-07\",\"gender\":\"male\",\"award\":[\"Devoxx Champion\",\"Couchbase Legend\"],\"knowsAbout\":[\"Java\"],\"knowsLanguage\":[\"English\",\"French\"],\"jobTitle\":\"Director Developer Relation & Strategy\",\"worksFor\":\"Couchbase\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/author\\\/laurent-doguin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Moving SQL database content to Couchbase - The Couchbase Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/","og_locale":"en_US","og_type":"article","og_title":"Moving SQL database content to Couchbase","og_description":"Since the GA release of N1QL, we get a lot of questions about moving content from a SQL database to Couchbase. There are many different ways to do so. Today, I have chosen what is probably the simplest. I will [&hellip;]","og_url":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/","og_site_name":"The Couchbase Blog","article_published_time":"2016-01-25T13:30:01+00:00","article_modified_time":"2025-06-14T00:33:08+00:00","author":"Laurent Doguin","twitter_card":"summary_large_image","twitter_creator":"@ldoguin","twitter_misc":{"Written by":"unstructured.io","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/"},"author":{"name":"Laurent Doguin","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c0aa9b8f1ed51b7a9e2f7cb755994a5e"},"headline":"Moving SQL database content to Couchbase","datePublished":"2016-01-25T13:30:01+00:00","dateModified":"2025-06-14T00:33:08+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/"},"wordCount":932,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","keywords":["jdbc"],"articleSection":["Application Design","Best Practices and Tutorials","SQL++ \/ N1QL Query"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/","url":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/","name":"Moving SQL database content to Couchbase - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2016-01-25T13:30:01+00:00","dateModified":"2025-06-14T00:33:08+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","width":1800,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/moving-sql-database-content-to-couchbase\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Moving SQL database content to Couchbase"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c0aa9b8f1ed51b7a9e2f7cb755994a5e","name":"Laurent Doguin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b8c466908092b46634af916b6921f30187a051e4367ded7ac9b1a3f2c5692fd2?s=96&d=mm&r=g12929ce99397769f362b7a90d6b85071","url":"https:\/\/secure.gravatar.com\/avatar\/b8c466908092b46634af916b6921f30187a051e4367ded7ac9b1a3f2c5692fd2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b8c466908092b46634af916b6921f30187a051e4367ded7ac9b1a3f2c5692fd2?s=96&d=mm&r=g","caption":"Laurent Doguin"},"description":"Laurent is a nerdy metal head who lives in Paris. He mostly writes code in Java and structured text in AsciiDoc, and often talks about data, reactive programming and other buzzwordy stuff. He is also a former Developer Advocate for Clever Cloud and Nuxeo where he devoted his time and expertise to helping those communities grow bigger and stronger. He now runs Developer Relations at Couchbase.","sameAs":["https:\/\/x.com\/ldoguin"],"honorificPrefix":"Mr","birthDate":"1985-06-07","gender":"male","award":["Devoxx Champion","Couchbase Legend"],"knowsAbout":["Java"],"knowsLanguage":["English","French"],"jobTitle":"Director Developer Relation & Strategy","worksFor":"Couchbase","url":"https:\/\/www.couchbase.com\/blog\/author\/laurent-doguin\/"}]}},"acf":[],"authors":[{"term_id":9023,"user_id":49,"is_guest":0,"slug":"laurent-doguin","display_name":"Laurent Doguin","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/b8c466908092b46634af916b6921f30187a051e4367ded7ac9b1a3f2c5692fd2?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/2130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/49"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=2130"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/2130\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/13873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=2130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=2130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=2130"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=2130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}