Question: Here I am using MySQL and I want my primary key to start with a letter, like D000. Then everytime I enter a new record the primary key auto increments like so:

D001
D002
D003.

How can I do this?

Answer: 
You can't `AUTO_INCREMENT` a column whose type is `VARCHAR`.

What you could do is make it `BIGINT` and `AUTO_INCREMENT`, and whenever you need it as `String`, you can prepend it with your letter `'D'` like:

```
Long dbKey = ...;
String key = "D" + dbKey;

```

You could create a stored procedure for this to set an "auto-incremented" string as the default value for this column, but it just doesn't worth the hassle. Plus working with numbers is always faster and more efficient than working with strings.
Not sure why you need it but you can add the `D` AFTER you fetched the data (`String id = "D" + autoIncId;`).

You can't insert a string or anything in an autoincrement field and I can't see anyway this can be useful (all the recorde will have a D, so no one has).

If you want to declare a row default, you can add a boolean column named `DEFAULT`.

```
while(rs.next()){
    String id = rs.getBoolean("DEFAULT")?"D":"ND";
    id+=rs.getLong(1);
}

```

EDIT
----

As per your comment I understand that you want to select the max ID and add 1 to it. Then it's ok to use an autoincrement field in your DB and it must be a number type (INTEGER, BIGINT...).

Please FORGET to add the "D" to your primary key, it will simply not going to work as you want. The autoincrement takes the last inserted ID and adds 1 to it. If your last id is "D3" adding 1 has the same meaning as adding 4 to "apple". You are using different types.

There is no way for SQL or any other programming language to understand that if you add 1 to "D3" it should become "D4". What you need to do is get rid of that D (which purpose I still don't understand).