SQLite Forum

Getting 'default' values: for a view?
Login
Is there a way of evaluating the 'default' expression for a table in a context other than INSERTing a new row?


### Example:

```
create table people(name text default 'fred');
insert into people default values; -- will insert 'fred'
insert into people values(null);
```

I am wondering if there is some construction that would allow me to generate the row - without actually necessarily persisting it - in the same way?

```
select ifnull(name,'I would like the default here') from people;
```

I can see how to *see* the expression; so for static strings , you can do this:

```
SELECT TRIM(dflt_value,"'") -- bad assumption
FROM pragma_table_info('people')
WHERE NAME='name'
```

The TRIM here is to remove the single quotes from the default; but that only works of course if the default happens to be a static string, rather than a calculated one.