Question: For a data ingester service, I'd like to strictly restrict its access to the database in the following way. This ingester service must be able to:

* Create new tables to store new kind of data (i.e. a dynamic ingester able to store new type of data on-the-fly).
* Add a new column to one of the tables the ingester created (backward-forward schema compatibility only).
* Insert new rows in one of the tables the ingester created.

Another way to specify this ingester role is to look at what it shouldn't be able to do:

* DROP any table, including the tables it created
* SELECT, DELETE, UPDATE any rows in any table
* Remove or update a column in any table

I didn't find any way to satisfy all these constraints with PostgreSQL. 
For example, to Alter a table the ingester role need to own the table, but when you own a table you automatically have access to DELETE, SELECT, UPDATE, ... operations on this table. Ideally, I'd like all these tables owned by a database admin user. This admin user will be the only user allowed to execute any destructive operations. 

Can we use a combination of trigger and function to satisfy those constraints or can we specify that only based on roles and grant operations?

Answer: 
Here, try this:

```
for( int i = n;  i > 0;  i-- )
   con += string.substring( 0, i );
System.out.println( con );

```

I have not tried it, but I believe it should work.

In any case, if you just think about it, it may help you understand what you need to do and why you need to do it this way and not some other way.
If you want first characters of a string, the first argument to `substring` must be 0. It is. Check.

If you want n, n-1, ... 1 characters of a string, the second argument to `substring` must be n, n-1, ... 1. In your loop, it obviously not. Your loop should be from n to 1 (or 0, but concatenating an empty string makes no sense).