How to view and change STATS retention?

Way of changing retention
SQL> select dbms_stats.get_stats_history_retention from dual;

GET_STATS_HISTORY_RETENTION
—————————
31

— value passed is in days
— If 0 is passed – old statistics are never saved. The automatic purge will delete all statistics history
— If 1 is passed – statistics history is never purged by automatic purge.
SQL> exec dbms_stats.alter_stats_history_retention(30);

PL/SQL procedure successfully completed.

SQL> select dbms_stats.get_stats_history_retention from dual;

GET_STATS_HISTORY_RETENTION
—————————
30