OracleÊý¾Ý¿âÖÐÔõÑùÏÞÖÆÓû§¶Ô±íµÄ²Ù×÷Ϊֻ¶Á£¿
ÔÚOracleÊý¾Ý¿âÖУ¬¿ÉÒÔͨ¹ýÊÚÓèÖ»¶ÁȨÏÞÀ´ÏÞÖÆÓû§¶Ô±íµÄ²Ù×÷Ϊֻ¶Á¡£ÏÂÃ潫ÏêϸÏÈÈÝÔõÑùÔÚOracleÊý¾Ý¿âÖÐʵÏÖÕâÒ»¹¦Ð§£¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£
½¨ÉèÒ»¸öеÄÖ»¶Á½ÇÉ«£º
CREATE ROLE readonly_role;
µÇ¼ºó¸´ÖÆ
½«¸Ã½ÇÉ«ÉèÖÃΪֻ¶ÁȨÏÞ£º
GRANT SELECT ON <±íÃû> TO readonly_role;
µÇ¼ºó¸´ÖÆ
ÕâÀïµÄ ΪҪÉèÖÃΪֻ¶ÁȨÏ޵ıíÃû£¬¿ÉÒÔƾ֤ÏÖÕæÏàÐÎÌ滻ΪÏêϸµÄ±íÃû¡£
½¨ÉèÒ»¸öеÄÓû§²¢·ÖÅÉÖ»¶Á½ÇÉ«£º
CREATE USER readonly_user IDENTIFIED BY password; GRANT readonly_role TO readonly_user;
µÇ¼ºó¸´ÖÆ
ÕâÀïµÄreadonly_userΪн¨ÉèµÄÖ»¶ÁÓû§£¬passwordΪÓû§ÃÜÂë¡£
²âÊÔÖ»¶ÁÓû§µÄ±í²Ù×÷ȨÏÞ£º
-- ÒÔÖ»¶ÁÓû§µÇ¼ CONNECT readonly_user/password; -- ʵÑé²åÈëÊý¾Ý INSERT INTO <±íÃû> (column1, column2) VALUES ('value1', 'value2'); --½«·µ»ØORA-01031: insufficient privileges¹ýʧ£¬ÌåÏÖ²åÈë²Ù×÷±»¾Ü¾ø -- ÅÌÎÊÊý¾Ý SELECT * FROM <±íÃû>; --½«ÀÖ³ÉÅÌÎʵ½±íÖеÄÊý¾Ý
µÇ¼ºó¸´ÖÆ
ͨ¹ýÒÔÉÏ°ì·¨£¬ÎÒÃÇÀֳɵØÔÚOracleÊý¾Ý¿âÖÐÏÞÖÆÁËÓû§¶ÔÌض¨±íµÄ²Ù×÷Ϊֻ¶Á¡£Ö»¶ÁÓû§Ö»ÄÜÅÌÎʱíÖеÄÊý¾Ý£¬¶øÎÞ·¨¾ÙÐвåÈë¡¢¸üлòɾ³ýµÈ²Ù×÷£¬´Ó¶øÓÐÓñ£»¤Êý¾ÝµÄÍêÕûÐÔºÍÇå¾²ÐÔ¡£
Ï£ÍûÒÔÉÏ´úÂëʾÀýÄܹ»×ÊÖúÄãÔÚOracleÊý¾Ý¿âÖÐʵÏÖ¶Ô±íµÄÖ»¶Á²Ù×÷ÏÞÖÆ¡£
ÒÔÉϾÍÊÇOracleÊý¾Ý¿âÖÐÔõÑùÏÞÖÆÓû§¶Ô±íµÄ²Ù×÷Ϊֻ¶Á£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡